|
|
@ -134,28 +134,7 @@ public class GradientBar extends AbstractComponentPopBox implements UIObserver, |
|
|
|
protected void addMouseDragListener() { |
|
|
|
protected void addMouseDragListener() { |
|
|
|
this.addMouseMotionListener(new MouseAdapter() { |
|
|
|
this.addMouseMotionListener(new MouseAdapter() { |
|
|
|
public void mouseDragged(MouseEvent e) { |
|
|
|
public void mouseDragged(MouseEvent e) { |
|
|
|
int oldIndex = index; |
|
|
|
dragAction(e); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
|
|
|
|
if (list.get(i).contains(e.getX(), e.getY())) { |
|
|
|
|
|
|
|
index = i; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (OperatingSystem.isLinux() && AssistUtils.equals(oldIndex, index)) { |
|
|
|
|
|
|
|
if (Math.abs(p1.getX() - e.getX()) > Math.abs(p2.getX() - e.getX())) { |
|
|
|
|
|
|
|
index = 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
index = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
boolean x = e.getX() <= max && e.getX() >= min; |
|
|
|
|
|
|
|
if (x && e.getY() < MAX_VERTICAL) { |
|
|
|
|
|
|
|
list.get(index).setX(e.getX()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GradientBar.this.repaint(); |
|
|
|
|
|
|
|
startLabel.setText(Double.toString(p1.getX())); |
|
|
|
|
|
|
|
endLabel.setText(Double.toString(p2.getX())); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -336,4 +315,29 @@ public class GradientBar extends AbstractComponentPopBox implements UIObserver, |
|
|
|
public void setDraggable(boolean draggable) { |
|
|
|
public void setDraggable(boolean draggable) { |
|
|
|
this.draggable = draggable; |
|
|
|
this.draggable = draggable; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void dragAction(MouseEvent e) { |
|
|
|
|
|
|
|
int oldIndex = index; |
|
|
|
|
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
|
|
|
|
if (list.get(i).contains(e.getX(), e.getY())) { |
|
|
|
|
|
|
|
index = i; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (OperatingSystem.isLinux() && AssistUtils.equals(oldIndex, index)) { |
|
|
|
|
|
|
|
if (Math.abs(p1.getX() - e.getX()) > Math.abs(p2.getX() - e.getX())) { |
|
|
|
|
|
|
|
index = 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
index = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
boolean x = e.getX() <= max && e.getX() >= min; |
|
|
|
|
|
|
|
if (x && e.getY() < MAX_VERTICAL) { |
|
|
|
|
|
|
|
list.get(index).setX(e.getX()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GradientBar.this.repaint(); |
|
|
|
|
|
|
|
startLabel.setText(Double.toString(p1.getX())); |
|
|
|
|
|
|
|
endLabel.setText(Double.toString(p2.getX())); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |