|
|
@ -7,11 +7,14 @@ package com.fr.design.style.color; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.general.FRLogger; |
|
|
|
import com.fr.general.FRLogger; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.event.*; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.geom.Ellipse2D; |
|
|
|
import java.awt.geom.Ellipse2D; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import javax.swing.*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 取色框 |
|
|
|
* 取色框 |
|
|
@ -32,7 +35,6 @@ public class ColorPicker extends JDialog implements ActionListener |
|
|
|
private ColorSelectable colorSelectable; |
|
|
|
private ColorSelectable colorSelectable; |
|
|
|
private Point mousePos; // 鼠标的绝对坐标
|
|
|
|
private Point mousePos; // 鼠标的绝对坐标
|
|
|
|
private Color colorToSet; // 暂存要设置的颜色值
|
|
|
|
private Color colorToSet; // 暂存要设置的颜色值
|
|
|
|
private Color initColor; // 保存初始颜色。实时模式下,如果取消取色操作,则重设为初始颜色
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Boolean setColorRealTime; // 实时设定颜色值
|
|
|
|
private Boolean setColorRealTime; // 实时设定颜色值
|
|
|
|
|
|
|
|
|
|
|
@ -67,7 +69,6 @@ public class ColorPicker extends JDialog implements ActionListener |
|
|
|
// 如果要求实时变化,确保先关闭弹窗,再截屏
|
|
|
|
// 如果要求实时变化,确保先关闭弹窗,再截屏
|
|
|
|
// 主要针对"图案"选项卡中的"前景"、"背景"
|
|
|
|
// 主要针对"图案"选项卡中的"前景"、"背景"
|
|
|
|
if (this.setColorRealTime) { |
|
|
|
if (this.setColorRealTime) { |
|
|
|
initColor = colorSelectable.getColor(); |
|
|
|
|
|
|
|
colorSelectable.setColor(Color.WHITE); // setColor 可以关闭弹窗
|
|
|
|
colorSelectable.setColor(Color.WHITE); // setColor 可以关闭弹窗
|
|
|
|
try { |
|
|
|
try { |
|
|
|
Thread.sleep(100); // 等待弹窗关闭
|
|
|
|
Thread.sleep(100); // 等待弹窗关闭
|
|
|
@ -112,10 +113,10 @@ public class ColorPicker extends JDialog implements ActionListener |
|
|
|
validate(); // 更新所有子控件
|
|
|
|
validate(); // 更新所有子控件
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void pickComplete(Color color) { |
|
|
|
public void pickComplete(boolean setColor) { |
|
|
|
timer.stop(); |
|
|
|
timer.stop(); |
|
|
|
if (color != null) { |
|
|
|
if (setColor) { |
|
|
|
colorSelectable.setColor(color); |
|
|
|
colorSelectable.setColor(colorToSet); |
|
|
|
} |
|
|
|
} |
|
|
|
this.dispose(); |
|
|
|
this.dispose(); |
|
|
|
} |
|
|
|
} |
|
|
@ -129,13 +130,8 @@ public class ColorPicker extends JDialog implements ActionListener |
|
|
|
|
|
|
|
|
|
|
|
private class MouseFunctions extends MouseAdapter |
|
|
|
private class MouseFunctions extends MouseAdapter |
|
|
|
{ |
|
|
|
{ |
|
|
|
public void mousePressed(MouseEvent e) |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
{ |
|
|
|
pickComplete(e.getButton() == e.BUTTON1); // 左键确定
|
|
|
|
if (e.getButton() == e.BUTTON1) { // 左键确定
|
|
|
|
|
|
|
|
pickComplete(colorToSet); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
pickComplete(setColorRealTime ? initColor : null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|