Browse Source

Merge pull request #621 in BA/design from ~PLOUGH/design:dev to dev

* commit 'a7fafda5a41b5f8b74206a4b24be38e03b26ac5e':
  REPORT-1096 取色板=》调整代码
  REPORT-1096 取色板=》调整代码
  无JIRA任务。修改代码
  REPORT-1096 取色板=》解决一些bug
  REPORT-1096 取色板=》将取色框改为模态对话框;修改鼠标事件响应方法
  REPORT-1096 取色板=》改为只在按下鼠标左键时设置颜色
master
superman 8 years ago
parent
commit
a8e17c2632
  1. 6
      designer/src/com/fr/design/actions/report/ReportBackgroundAction.java
  2. 40
      designer_base/src/com/fr/design/style/color/ColorPicker.java
  3. 2
      designer_base/src/com/fr/design/style/color/ColorSelectDialog.java
  4. 10
      designer_base/src/com/fr/design/style/color/PickColorButtonFactory.java

6
designer/src/com/fr/design/actions/report/ReportBackgroundAction.java

@ -37,16 +37,14 @@ public class ReportBackgroundAction extends ReportComponentAction<ReportComponen
}
final ReportBackgroundPane bPane = new ReportBackgroundPane();
bPane.populate(ReportUtils.getReportSettings(reportPane.getTemplateReport()));
BasicDialog bDialog = bPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
bPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
bPane.update(reportPane.getTemplateReport().getReportSettings());
reportPane.fireTargetModified();
}
});
bDialog.setModal(false);
bDialog.setVisible(true);
}).setVisible(true);
return false;
}
}

40
designer_base/src/com/fr/design/style/color/ColorPicker.java

@ -5,6 +5,7 @@ package com.fr.design.style.color;
*/
import com.fr.base.BaseUtils;
import com.fr.general.FRLogger;
import java.awt.*;
import java.awt.event.*;
@ -49,7 +50,10 @@ public class ColorPicker extends JDialog implements ActionListener
updateSize(colorPickerSize);
this.colorSelectable = colorSelectable;
this.setColorRealTime = setColorRealTime;
start();
this.setModal(true);
this.setAlwaysOnTop(true);
updateLocation();
this.setVisible(true);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
}
@ -58,6 +62,18 @@ public class ColorPicker extends JDialog implements ActionListener
timer = new Timer(timeCycle, this);
timer.start();
hideCursor();
// 如果要求实时变化,确保先关闭弹窗,再截屏
// 主要针对"图案"选项卡中的"前景"、"背景"
if (this.setColorRealTime) {
colorSelectable.setColor(Color.WHITE); // setColor 可以关闭弹窗
try {
Thread.sleep(100); // 等待弹窗关闭
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
}
colorPickerPanel.captureScreen();
}
// System.out.println(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow());
}
@ -68,7 +84,7 @@ public class ColorPicker extends JDialog implements ActionListener
public void actionPerformed(ActionEvent e) {
updateLocation();
colorToSet = colorPickerPanel.getPixelColor(mousePos);
if (setColorRealTime && !colorSelectable.getColor().equals(colorToSet)) {
if (setColorRealTime && (colorSelectable.getColor() == null || !colorSelectable.getColor().equals(colorToSet))) {
colorSelectable.setColor(colorToSet);
}
}
@ -94,9 +110,11 @@ public class ColorPicker extends JDialog implements ActionListener
validate(); // 更新所有子控件
}
public void pickComplete() {
public void pickComplete(boolean setColor) {
timer.stop();
colorSelectable.setColor(colorToSet);
if (setColor) {
colorSelectable.setColor(colorToSet);
}
this.dispose();
}
@ -109,9 +127,8 @@ public class ColorPicker extends JDialog implements ActionListener
private class MouseFunctions extends MouseAdapter
{
public void mousePressed(MouseEvent e)
{
pickComplete();
public void mousePressed(MouseEvent e) {
pickComplete(e.getButton() == e.BUTTON1); // 左键确定
}
}
}
@ -138,6 +155,15 @@ class ColorPickerPanel extends JPanel
*/
public ColorPickerPanel(int scaleFactor)
{
colorPickerFrame = BaseUtils.readImage("/com/fr/design/images/gui/colorPicker/colorPickerFrame.png");
this.scaleFactor = scaleFactor;
captureScreen();
}
/**
* 截屏
*/
public void captureScreen() {
try
{
robot = new Robot();
@ -149,8 +175,6 @@ class ColorPickerPanel extends JPanel
screenImage = robot.createScreenCapture(new Rectangle(0, 0, Toolkit
.getDefaultToolkit().getScreenSize().width, Toolkit
.getDefaultToolkit().getScreenSize().height));
colorPickerFrame = BaseUtils.readImage("/com/fr/design/images/gui/colorPicker/colorPickerFrame.png");
this.scaleFactor = scaleFactor;
}
/**

2
designer_base/src/com/fr/design/style/color/ColorSelectDialog.java

@ -137,7 +137,7 @@ public class ColorSelectDialog extends MiddleChartDialog{
public static void showDialog(Frame owner,ColorSelectDetailPane pane,Color initialColor,ColorSelectable selectePane){
ColorTracker okListener = new ColorTracker(pane);
ColorSelectDialog dialog = new ColorSelectDialog(owner,pane,initialColor,okListener,selectePane);
// dialog.setModal(true);
dialog.setModal(true);
dialog.show();
}

10
designer_base/src/com/fr/design/style/color/PickColorButtonFactory.java

@ -4,8 +4,7 @@ import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.*;
/**
* Created by plough on 2016/12/22.
@ -28,11 +27,10 @@ public class PickColorButtonFactory {
}
pickColorButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
pickColorButton.addActionListener(new ActionListener() {
pickColorButton.addMouseListener(new MouseAdapter() {
@Override
public void actionPerformed(ActionEvent e) {
ColorPicker colorPicker = new ColorPicker(colorSelectable, setColorRealTime);
colorPicker.start();
public void mousePressed(MouseEvent e) {
new ColorPicker(colorSelectable, setColorRealTime);
}
});

Loading…
Cancel
Save