|
|
|
@ -7,7 +7,6 @@ import com.fr.design.event.UIObserverListener;
|
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
import com.fr.design.style.background.gradient.SelectColorPointBtn; |
|
|
|
|
import com.fr.design.style.color.ColorCell; |
|
|
|
|
import com.fr.design.style.color.ColorSelectConfigManager; |
|
|
|
|
import com.fr.design.style.color.ColorSelectDetailPane; |
|
|
|
|
import com.fr.design.style.color.ColorSelectDialog; |
|
|
|
|
import com.fr.design.style.color.ColorSelectable; |
|
|
|
@ -18,6 +17,9 @@ import com.fr.stable.AssistUtils;
|
|
|
|
|
import javax.swing.JComponent; |
|
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.awt.Color; |
|
|
|
|
import java.awt.Cursor; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
@ -27,9 +29,6 @@ import java.awt.LinearGradientPaint;
|
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
import java.awt.geom.Point2D; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
public class LegendGradientBar extends JComponent implements ColorSelectable, UIObserver { |
|
|
|
|
|
|
|
|
@ -168,12 +167,14 @@ public class LegendGradientBar extends JComponent implements ColorSelectable, UI
|
|
|
|
|
SelectColorPointBtn pi = new SelectColorPointBtn(((startPos + endPos) / (pColors.length + 1)) * (i + 1), REC_HEIGHT, pColors[i]); |
|
|
|
|
selectColorPointBtnList.add(pi); |
|
|
|
|
} |
|
|
|
|
refreshColorsAndDist(selectColorPointBtnList); |
|
|
|
|
this.repaint(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 添加事件 |
|
|
|
|
* |
|
|
|
|
* @param changeListener 事件 |
|
|
|
|
*/ |
|
|
|
|
public void addChangeListener(ChangeListener changeListener) { |
|
|
|
@ -216,7 +217,7 @@ public class LegendGradientBar extends JComponent implements ColorSelectable, UI
|
|
|
|
|
//如果该位置已经有滑块占领,则做跨越偏移
|
|
|
|
|
selectColorPointBtnList.get(index).setX(LegendGradientBar.this.setOffset(e.getX(), index, OFFSETSTEP)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
refreshColorsAndDist(selectColorPointBtnList); |
|
|
|
|
LegendGradientBar.this.repaint(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -229,8 +230,7 @@ public class LegendGradientBar extends JComponent implements ColorSelectable, UI
|
|
|
|
|
if (x >= (min + max) / 2) { |
|
|
|
|
x -= offset; |
|
|
|
|
x = setOffset(x, index, offset + OFFSETSTEP); |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
} else { |
|
|
|
|
x += offset; |
|
|
|
|
x = setOffset(x, index, offset + OFFSETSTEP); |
|
|
|
|
} |
|
|
|
@ -240,8 +240,7 @@ public class LegendGradientBar extends JComponent implements ColorSelectable, UI
|
|
|
|
|
//边界情况
|
|
|
|
|
if (x <= min) { |
|
|
|
|
x = min + (index + 1) * OFFSETSTEP; |
|
|
|
|
} |
|
|
|
|
else if (x >= max){ |
|
|
|
|
} else if (x >= max) { |
|
|
|
|
x = max - (index + 1) * OFFSETSTEP; |
|
|
|
|
} |
|
|
|
|
return x; |
|
|
|
@ -259,48 +258,31 @@ public class LegendGradientBar extends JComponent implements ColorSelectable, UI
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (select >= 0) { |
|
|
|
|
ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); |
|
|
|
|
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, LegendGradientBar.this); |
|
|
|
|
Color color = LegendGradientBar.this.getColor(); |
|
|
|
|
if (color != null) { |
|
|
|
|
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); |
|
|
|
|
selectColorPointBtnList.get(select).setColorInner(color); |
|
|
|
|
|
|
|
|
|
LegendGradientBar.this.repaint(); |
|
|
|
|
dealClick(selectColorPointBtnList.get(select)); |
|
|
|
|
} else if (selectColorSlotBtnStart.contains(e.getX(), e.getY())) { |
|
|
|
|
dealClick(selectColorSlotBtnStart); |
|
|
|
|
} else if (selectColorSlotBtnEnd.contains(e.getX(), e.getY())) { |
|
|
|
|
dealClick(selectColorSlotBtnEnd); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//是否选中颜色编辑槽
|
|
|
|
|
else if (selectColorSlotBtnStart.contains(e.getX(), e.getY())) { |
|
|
|
|
ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); |
|
|
|
|
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, LegendGradientBar.this); |
|
|
|
|
Color color = LegendGradientBar.this.getColor(); |
|
|
|
|
if (color != null) { |
|
|
|
|
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); |
|
|
|
|
selectColorSlotBtnStart.setColorInner(color); |
|
|
|
|
//stateChanged();
|
|
|
|
|
LegendGradientBar.this.repaint(); |
|
|
|
|
} |
|
|
|
|
} else if (selectColorSlotBtnEnd.contains(e.getX(), e.getY())) { |
|
|
|
|
|
|
|
|
|
private void dealClick(SelectColorPointBtn selectColorPointBtn) { |
|
|
|
|
ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); |
|
|
|
|
this.setColor(selectColorPointBtn.getColorInner()); |
|
|
|
|
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, LegendGradientBar.this); |
|
|
|
|
Color color = LegendGradientBar.this.getColor(); |
|
|
|
|
Color color = this.getColor(); |
|
|
|
|
if (color != null) { |
|
|
|
|
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); |
|
|
|
|
selectColorSlotBtnEnd.setColorInner(color); |
|
|
|
|
//stateChanged();
|
|
|
|
|
LegendGradientBar.this.repaint(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
selectColorPointBtn.setColorInner(color); |
|
|
|
|
refreshColorsAndDist(selectColorPointBtnList); |
|
|
|
|
LegendGradientBar.this.repaint(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void addMouseReleasedListener() { |
|
|
|
|
this.addMouseListener(new MouseAdapter() { |
|
|
|
@ -318,9 +300,6 @@ public class LegendGradientBar extends JComponent implements ColorSelectable, UI
|
|
|
|
|
Point2D start = new Point2D.Float(4, 0); |
|
|
|
|
Point2D end = new Point2D.Float(max, 0); |
|
|
|
|
|
|
|
|
|
//获取排序后的颜色数组和位置数组
|
|
|
|
|
refreshColorsAndDist(selectColorPointBtnList); |
|
|
|
|
|
|
|
|
|
LinearGradientPaint paint = new LinearGradientPaint(start, end, dist, colors); |
|
|
|
|
g2.setPaint(paint); |
|
|
|
|
|
|
|
|
|