diff --git a/build.performance.gradle b/build.performance.gradle new file mode 100644 index 000000000..132db468f --- /dev/null +++ b/build.performance.gradle @@ -0,0 +1,75 @@ +apply plugin: "java" +tasks.withType(JavaCompile){ + options.encoding = "UTF-8" +} + +def basicDir="../" +def libDir="${basicDir}/lib" + +task appletJar<<{ + ant{ + mkdir(dir:"./tmp") + mkdir(dir:"build/classes/main") + copy(todir:"build/classes/"){ + fileset(dir:"${basicDir}/core/build/classes/main") + fileset(dir:"${basicDir}/chart/build/classes/main") + fileset(dir:"${basicDir}/report/build/classes/main") + fileset(dir:"${basicDir}/platform/build/classes/main") + } + unjar(src:"${libDir}/3rd.jar",dest:"./tmp") + unjar(src:"${libDir}/servlet-api.jar",dest:"./tmp") + jar(jarfile:"build/libs/fr-applet-8.0.jar"){ + fileset(dir:"build/classes"){ + exclude(name:"*.*") + exclude(name:"bin/*.*") + exclude(name:"classes/**") + exclude(name:"com/fr/schedule/**") + exclude(name:"com/fr/cell/**") + exclude(name:"com/fr/dialog/**") + exclude(name:"com/fr/view/**") + exclude(name:"com/fr/web/**") + exclude(name:"com/fr/fs/**") + exclude(name:"com/fr/design/**") + exclude(name:"com/fr/start/**") + exclude(name:"com/fr/process/**") + } + fileset(dir:"./tmp"){ + include(name:"javax/mail/**") + include(name:"javax/servlet/**") + include(name:"org/freehep/**") + include(name:"com/fr/third/JAI/**") + include(name:"com/fr/third/antlr/**") + include(name:"com/fr/third/javax/**") + include(name:"com/sun/xml/**") + include(name:"javax/xml/**") + + } + fileset(dir:"build/classes"){ + include(name:"com/fr/web/*.class") + include(name:"com/fr/web/attr/*.class") + } + } + delete(dir:"./tmp") + def jdk6home= "D:/FineReport/develop/java/jdk1.6u35" + def keystore="frapplet.store" + def keycert="fr.cert" + def keypassword="123456" + def keyalias="fr" + + exec(executable:"${jdk6home}/bin/keytool"){ + arg(line:"-genkey -dname "CN=FineReport L=NanJing C=China" -keystore ${keystore} -alias ${keyalias} -validity 3650 -storepass ${keypassword}") + } + exec(executable:"${jdk6home}/bin/keytool"){ + arg(line:"-export -keystore ${keystore} -alias ${keyalias} -file ${keycert} -storepass ${keypassword}") + } + + exec(executable:"${jdk6home}/bin/jarsigner"){ + arg(line:"-keystore ${keystore} -storepass ${keypassword} 'build/libs/fr-applet-8.0.jar' ${keyalias}") + } + delete(file:"${keystore}") + delete(file:"${keycert}") + delete(dir:"build/classes") + + } + +} \ No newline at end of file diff --git a/build.performance.gradle.bak b/build.performance.gradle.bak new file mode 100644 index 000000000..58899a9c2 --- /dev/null +++ b/build.performance.gradle.bak @@ -0,0 +1,76 @@ +apply plugin: "java" +tasks.withType(JavaCompile){ + options.encoding = "UTF-8" +} + +def basicDir="../" +def libDir="${basicDir}/lib" + +task appletJar<<{ + ant{ + mkdir(dir:"./tmp") + mkdir(dir:"build/classes/main") + copy(todir:"build/classes/"){ + fileset(dir:"${basicDir}/core/build/classes/main") + fileset(dir:"${basicDir}/chart/build/classes/main") + fileset(dir:"${basicDir}/report/build/classes/main") + fileset(dir:"${basicDir}/platform/build/classes/main") + fileset(dir:"${basicDir}/performance/build/classes/main") + } + unjar(src:"${libDir}/3rd.jar",dest:"./tmp") + unjar(src:"${libDir}/servlet-api.jar",dest:"./tmp") + jar(jarfile:"build/libs/fr-applet-8.0.jar"){ + fileset(dir:"build/classes"){ + exclude(name:"*.*") + exclude(name:"bin/*.*") + exclude(name:"classes/**") + exclude(name:"com/fr/schedule/**") + exclude(name:"com/fr/cell/**") + exclude(name:"com/fr/dialog/**") + exclude(name:"com/fr/view/**") + exclude(name:"com/fr/web/**") + exclude(name:"com/fr/fs/**") + exclude(name:"com/fr/design/**") + exclude(name:"com/fr/start/**") + exclude(name:"com/fr/process/**") + } + fileset(dir:"./tmp"){ + include(name:"javax/mail/**") + include(name:"javax/servlet/**") + include(name:"org/freehep/**") + include(name:"com/fr/third/JAI/**") + include(name:"com/fr/third/antlr/**") + include(name:"com/fr/third/javax/**") + include(name:"com/sun/xml/**") + include(name:"javax/xml/**") + + } + fileset(dir:"build/classes"){ + include(name:"com/fr/web/*.class") + include(name:"com/fr/web/attr/*.class") + } + } + delete(dir:"./tmp") + def jdk6home= "D:/FineReport/develop/java/jdk1.6u35" + def keystore="frapplet.store" + def keycert="fr.cert" + def keypassword="123456" + def keyalias="fr" + + exec(executable:"${jdk6home}/bin/keytool"){ + arg(line:"-genkey -dname "CN=FineReport L=NanJing C=China" -keystore ${keystore} -alias ${keyalias} -validity 3650 -storepass ${keypassword}") + } + exec(executable:"${jdk6home}/bin/keytool"){ + arg(line:"-export -keystore ${keystore} -alias ${keyalias} -file ${keycert} -storepass ${keypassword}") + } + + exec(executable:"${jdk6home}/bin/jarsigner"){ + arg(line:"-keystore ${keystore} -storepass ${keypassword} 'build/libs/fr-applet-8.0.jar' ${keyalias}") + } + delete(file:"${keystore}") + delete(file:"${keycert}") + delete(dir:"build/classes") + + } + +} \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/cell/NewPresentAction.java b/designer/src/com/fr/design/actions/cell/NewPresentAction.java index a35333d61..ac9fef472 100644 --- a/designer/src/com/fr/design/actions/cell/NewPresentAction.java +++ b/designer/src/com/fr/design/actions/cell/NewPresentAction.java @@ -26,7 +26,7 @@ public class NewPresentAction extends PresentCheckBoxAction { @Override public boolean executeActionReturnUndoRecordNeeded() { if (!ComparatorUtils.equals(this.itemName, "NOPRESENT")) { - CellElementPropertyPane.getInstance().GoToPane(Inter.getLocText("Present"), this.itemName); + CellElementPropertyPane.getInstance().GoToPane(Inter.getLocText("FR-Designer_Present"), this.itemName); } else { TemplateCellElement ce = getSelectedCellElement(); // 只有原来ce设置了形态的情况下才有undo操作 @@ -73,7 +73,7 @@ public class NewPresentAction extends PresentCheckBoxAction { try { Class clazz = GeneralUtils.classForName(itemName); if (itemName.equals(currentPresent.getClass().getName())) { - return StableUtils.classInstanceOf(currentPresent.getClass(), clazz); + return StableUtils.objectInstanceOf(currentPresent, clazz); } } catch (Exception e) { return "NOPRESENT".equals(itemName) && currentPresent == null; diff --git a/designer/src/com/fr/design/actions/file/export/AbstractExportAction.java b/designer/src/com/fr/design/actions/file/export/AbstractExportAction.java index 0c6f0c8ed..e80e75fb9 100644 --- a/designer/src/com/fr/design/actions/file/export/AbstractExportAction.java +++ b/designer/src/com/fr/design/actions/file/export/AbstractExportAction.java @@ -5,7 +5,6 @@ package com.fr.design.actions.file.export; import com.fr.base.FRContext; import com.fr.base.Parameter; -import com.fr.io.exporter.pdfstream.PDFStreamExporter; import com.fr.page.PageSetProvider; import com.fr.design.actions.JWorkBookAction; import com.fr.design.gui.iprogressbar.FRProgressBar; @@ -94,10 +93,10 @@ public abstract class AbstractExportAction extends JWorkBookAction { FRLogger.getLogger().error("Error In Make New File"); } fileChooserPane = null; - FRContext.getLogger().info("\"" + file.getName() + "\"" + Inter.getLocText("Prepare_Export") + "!"); + FRContext.getLogger().info("\"" + file.getName() + "\"" + Inter.getLocText("FR-Designer_Prepare_Export") + "!"); (progressbar = new FRProgressBar(createExportWork(file, tpl, parameterMap), designerFrame, - Inter.getLocText("Exporting"), "", 0, 100)).start(); + Inter.getLocText("FR-Designer_Exporting"), "", 0, 100)).start(); } } @@ -117,13 +116,13 @@ public abstract class AbstractExportAction extends JWorkBookAction { fileOutputStream.close(); this.setProgress(100); - FRContext.getLogger().info("\"" + fileGetName + "\"" + Inter.getLocText("Finish_Export") + "!"); + FRContext.getLogger().info("\"" + fileGetName + "\"" + Inter.getLocText("FR-Designer_Finish_Export") + "!"); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Inter.getLocText("Exported_successfully") + "\n" + filePath); + Inter.getLocText("FR-Designer_Exported_successfully") + "\n" + filePath); } catch (Exception exp) { this.setProgress(100); FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Export_failed") + "\n" + filePath); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Export_failed") + "\n" + filePath); } return null; } @@ -140,7 +139,7 @@ public abstract class AbstractExportAction extends JWorkBookAction { if (exporter instanceof AppExporter) { AppExporter appExporter = (AppExporter) exporter; if (exporter instanceof ExcelExporter || exporter instanceof CSVExporter - || exporter instanceof PDFExporter || exporter instanceof PDFStreamExporter || exporter instanceof WordExporter) { + || exporter instanceof PDFExporterProcessor || exporter instanceof WordExporter) { ReportHelper.clearFormulaResult(tpl);// 清空rpt中的公式计算结果 appExporter.export(fileOutputStream, tpl.execute(parameterMap, ActorFactory.getActor(ActorConstants.TYPE_PAGE) diff --git a/designer/src/com/fr/design/actions/file/export/PDFExportAction.java b/designer/src/com/fr/design/actions/file/export/PDFExportAction.java index 64cf5dabf..15082031b 100644 --- a/designer/src/com/fr/design/actions/file/export/PDFExportAction.java +++ b/designer/src/com/fr/design/actions/file/export/PDFExportAction.java @@ -9,8 +9,7 @@ import com.fr.design.menu.KeySetUtils; import com.fr.file.filter.ChooseFileFilter; import com.fr.general.Inter; import com.fr.io.exporter.Exporter; -import com.fr.io.exporter.PDFExporter; -import com.fr.io.exporter.pdfstream.PDFStreamExporter; +import com.fr.web.core.reserve.PDFExporterFactory; /** * Export pdf @@ -29,12 +28,13 @@ public class PDFExportAction extends AbstractExportAction { @Override protected Exporter getExporter() { - return new PDFStreamExporter(); + + return PDFExporterFactory.getPDFExporter(); } @Override protected ChooseFileFilter getChooseFileFilter() { - return new ChooseFileFilter(new String[]{"pdf"}, Inter.getLocText("Export-PDF")); + return new ChooseFileFilter(new String[]{"pdf"}, Inter.getLocText("FR-Designer_Export-PDF")); } @Override diff --git a/designer/src/com/fr/design/actions/report/ReportBackgroundAction.java b/designer/src/com/fr/design/actions/report/ReportBackgroundAction.java index 6e8fd84f0..3c3940dda 100644 --- a/designer/src/com/fr/design/actions/report/ReportBackgroundAction.java +++ b/designer/src/com/fr/design/actions/report/ReportBackgroundAction.java @@ -5,6 +5,7 @@ package com.fr.design.actions.report; import com.fr.base.BaseUtils; import com.fr.design.actions.ReportComponentAction; +import com.fr.design.dialog.BasicDialog; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ReportComponent; import com.fr.design.menu.KeySetUtils; @@ -36,14 +37,16 @@ public class ReportBackgroundAction extends ReportComponentAction list = new java.util.ArrayList(); java.util.Iterator nameIt = this.getBook().getTableDataNameIterator(); while (nameIt.hasNext()) { diff --git a/designer_base/build.performance.gradle b/designer_base/build.performance.gradle new file mode 100644 index 000000000..af0dc75f0 --- /dev/null +++ b/designer_base/build.performance.gradle @@ -0,0 +1,69 @@ + +apply plugin: 'java' +tasks.withType(JavaCompile){ + options.encoding = 'UTF-8' +} +//指定构建的jdk版本 +sourceCompatibility=1.7 +//指定生成jar包版本 +version='8.0' +//生成jar包重命名 +jar{ + baseName='fr-designer-core' +} + + +def srcDir="." +def baseDir=".." + +//指定源码路径 +sourceSets{ + main{ + java{ + srcDirs=["${srcDir}/src"] + } + } +} +//获取什么分支名 +FileTree files =fileTree(dir:'./',include:'build.*.gradle') +def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\')) +buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\')) +def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1) + +//声明外部依赖 +dependencies{ + compile fileTree(dir:"../${baseDir}/lib",include:'**/*.jar') + compile fileTree(dir:"../${baseDir}",include:"**/build/libs/*.jar",exclude:"bi/**/*.jar") + testCompile 'junit:junit:4.12' +} +//复制非.java文件到classes文件夹下参与打包 +task copyFile(type:Copy,dependsOn:compileJava){ + copy{ + from ("${srcDir}/src"){ + exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html' + } + into 'build/classes/main' + } + +} + + +//压缩项目中的js文件 +task compressJS{ + ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ + classpath { + fileset(dir:"../${baseDir}/lib4build",includes:'**/*.jar') + } + } + ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){ + fileset (dir:"${srcDir}/src"){ + include (name:'**/*.js') + include (name:'**/*.css') + } + + } +} +jar.dependsOn compressJS + + + diff --git a/designer_base/build.performance.gradle.bak b/designer_base/build.performance.gradle.bak new file mode 100644 index 000000000..225b0e48d --- /dev/null +++ b/designer_base/build.performance.gradle.bak @@ -0,0 +1,69 @@ + +apply plugin: 'java' +tasks.withType(JavaCompile){ + options.encoding = 'UTF-8' +} +//指定构建的jdk版本 +sourceCompatibility=1.7 +//指定生成jar包版本 +version='8.0' +//生成jar包重命名 +jar{ + baseName='fr-designer-core' +} + + +def srcDir="." +def baseDir=".." + +//指定源码路径 +sourceSets{ + main{ + java{ + srcDirs=["${srcDir}/src"] + } + } +} +//获取什么分支名 +FileTree files =fileTree(dir:'./',include:'build.*.gradle') +def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\')) +buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\')) +def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1) + +//声明外部依赖 +dependencies{ + compile fileTree(dir:"../${baseDir}/lib",include:'**/*.jar') + compile fileTree(dir:"../${baseDir}",include:"**/build/libs/*.jar",exclude:"bi/**/*.jar") + testCompile 'junit:junit:4.12' +} +//复制非.java文件到classes文件夹下参与打包 +task copyFile(type:Copy,dependsOn:compileJava){ + copy{ + from ("${srcDir}/src"){ + exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html' + } + into 'build/classes/main' + } + +} + + +//压缩项目中的js文件 +task compressJS{ + ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ + classpath { + fileset(dir:'../${baseDir}/lib4build',includes:'**/*.jar') + } + } + ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){ + fileset (dir:"${srcDir}/src"){ + include (name:'**/*.js') + include (name:'**/*.css') + } + + } +} +jar.dependsOn compressJS + + + diff --git a/designer_base/src/com/fr/design/data/datapane/preview/PreviewTableModel.java b/designer_base/src/com/fr/design/data/datapane/preview/PreviewTableModel.java index d7918609c..9cd3d6034 100644 --- a/designer_base/src/com/fr/design/data/datapane/preview/PreviewTableModel.java +++ b/designer_base/src/com/fr/design/data/datapane/preview/PreviewTableModel.java @@ -50,7 +50,7 @@ public class PreviewTableModel extends AbstractTableModel { maxRowCount = rowCount; } final int finalRowCount = maxRowCount; - DataModel dm = new DataModel() { + DataModel dm = new AbstractDataModel() { @Override public void release() throws Exception { @@ -100,7 +100,7 @@ public class PreviewTableModel extends AbstractTableModel { } catch (TableDataException e) { FRContext.getLogger().error(e.getMessage(), e); DesignUtils.errorMessage(e.getMessage()); - return Inter.getLocText("Error"); + return Inter.getLocText("FR-Designer_Error"); } } @@ -149,7 +149,7 @@ public class PreviewTableModel extends AbstractTableModel { } public String getColumnName(int column) { - return Inter.getLocText("Error"); + return Inter.getLocText("FR-Designer_Error"); } public int getColumnCount() { @@ -166,7 +166,7 @@ public class PreviewTableModel extends AbstractTableModel { private String checkType(int column) { if (dateIndexs.contain(column)) { - String s = Inter.getLocText("Date"); + String s = Inter.getLocText("FR-Designer_Date"); return ("(" + s + ")"); } @@ -187,23 +187,23 @@ public class PreviewTableModel extends AbstractTableModel { if (o == null) { s = "?"; } else if (o instanceof String) { - s = Inter.getLocText("Parameter-String"); + s = Inter.getLocText("FR-Designer_Parameter_String"); if (FRContext.getCurrentEnv() instanceof RemoteEnv && dataModel instanceof EmbeddedTDDataModel) { Class clzz = ((EmbeddedTDDataModel) dataModel).getColumnClass(column); if (Number.class.isAssignableFrom(clzz)) { - s = Inter.getLocText("Number");//bigdecimal + s = Inter.getLocText("FR-Designer_Number");//bigdecimal } else if (java.sql.Date.class.isAssignableFrom(clzz)) { - s = Inter.getLocText("Date"); + s = Inter.getLocText("FR-Designer_Date"); } } } else if (o instanceof Integer) { - s = Inter.getLocText("Integer"); + s = Inter.getLocText("FR-Designer_Integer"); } else if (o instanceof Double || o instanceof Float) { - s = Inter.getLocText("Double"); + s = Inter.getLocText("FR-Designer_Double"); } else if (o instanceof java.sql.Date || o instanceof java.util.Date) { - s = Inter.getLocText("Date"); + s = Inter.getLocText("FR-Designer_Date"); } else if (o instanceof Number) { - s = Inter.getLocText("Number");//bigdecimal + s = Inter.getLocText("FR-Designer_Number");//bigdecimal } else { s = "?"; } diff --git a/designer_base/src/com/fr/design/extra/PluginConstants.java b/designer_base/src/com/fr/design/extra/PluginConstants.java deleted file mode 100644 index 4704ed129..000000000 --- a/designer_base/src/com/fr/design/extra/PluginConstants.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fr.design.extra; - -/** - * @author richie - * @date 2015-03-11 - * @since 8.0 - */ -public class PluginConstants { - - - public static final int BYTES_NUM = 1024; - - - -} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index 02f368032..119858206 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -7,6 +7,7 @@ import com.fr.design.extra.plugindependence.DownLoadDependenceUI; import com.fr.general.*; import com.fr.general.http.HttpClient; import com.fr.plugin.Plugin; +import com.fr.stable.plugin.PluginConstants; import com.fr.plugin.PluginLoader; import com.fr.plugin.PluginManagerHelper; import com.fr.plugin.dependence.PluginDependence; diff --git a/designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java b/designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java index 958d8d160..29097a5ee 100644 --- a/designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java +++ b/designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java @@ -1,8 +1,8 @@ package com.fr.design.extra.plugindependence; import com.fr.base.FRContext; -import com.fr.design.extra.PluginConstants; import com.fr.design.extra.PluginHelper; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.DesignerContext; import com.fr.general.IOUtils; import com.fr.general.Inter; @@ -12,6 +12,7 @@ import com.fr.plugin.dependence.PluginDependenceException; import com.fr.plugin.dependence.PluginDependenceUnit; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.plugin.PluginConstants; import javax.swing.*; import java.awt.*; @@ -20,7 +21,9 @@ import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; -import java.io.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; import java.net.HttpURLConnection; import java.util.List; @@ -40,8 +43,12 @@ public class DownLoadDependenceUI implements ActionListener { private boolean flag = true; // 定义加载窗口大小 - private final int LOAD_WIDTH = 455; - private final int LOAD_HEIGHT = 295; + private static final int LOAD_WIDTH = 455; + + private static final int INCIDENT_WIDTH = 15; + + private static final int LOAD_HEIGHT = 295; + //安装环境相关信息 private String currentID; @@ -68,8 +75,8 @@ public class DownLoadDependenceUI implements ActionListener { // 创建标签,并在标签上放置一张图片 BufferedImage image = IOUtils.readImage("/com/fr/design/extra/plugindependence/image/background.png"); ImageIcon imageIcon = new ImageIcon(image); - label = new JLabel(imageIcon); - label.setBounds(0, 0, LOAD_WIDTH, LOAD_HEIGHT - 15); + label = new UILabel(imageIcon); + label.setBounds(0, 0, LOAD_WIDTH, LOAD_HEIGHT - INCIDENT_WIDTH); progressbar = new JProgressBar(); // 显示当前进度值信息 @@ -80,7 +87,7 @@ public class DownLoadDependenceUI implements ActionListener { progressbar.setForeground(new Color(0x38aef5)); // 设置进度条的背景色 progressbar.setBackground(new Color(188, 190, 194)); - progressbar.setBounds(0, LOAD_HEIGHT - 15, LOAD_WIDTH, 15); + progressbar.setBounds(0, LOAD_HEIGHT - INCIDENT_WIDTH, LOAD_WIDTH, INCIDENT_WIDTH); progressbar.setMinimum(0); progressbar.setMaximum(totalSize); progressbar.setValue(0); @@ -249,7 +256,8 @@ public class DownLoadDependenceUI implements ActionListener { } public void installOnline()throws PluginDependenceException { - int choose = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer-Plugin_Plugin") + Inter.getLocText("FR-Designer-Need") + Inter.getLocText("FR-Designer-Dependence") + Inter.getLocText("FR-Designer-Support") + "," + Inter.getLocText("FR-Designer-Dependence_Need_Install") + "(" + showFileLength() + " m)?", "install tooltip", JOptionPane.YES_NO_OPTION); + + int choose = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer-Plugin_DownLoadMessage", showFileLength()), "install tooltip", JOptionPane.YES_NO_OPTION); if (choose == 0) {//下载安装 if (!connectToServer()) { throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Connect_Server_Error")); diff --git a/designer_base/src/com/fr/design/images/gui/colorPicker/colorPicker16.png b/designer_base/src/com/fr/design/images/gui/colorPicker/colorPicker16.png new file mode 100644 index 000000000..fc88b3bfc Binary files /dev/null and b/designer_base/src/com/fr/design/images/gui/colorPicker/colorPicker16.png differ diff --git a/designer_base/src/com/fr/design/images/gui/colorPicker/colorPicker18.png b/designer_base/src/com/fr/design/images/gui/colorPicker/colorPicker18.png new file mode 100644 index 000000000..afe0cd8eb Binary files /dev/null and b/designer_base/src/com/fr/design/images/gui/colorPicker/colorPicker18.png differ diff --git a/designer_base/src/com/fr/design/images/gui/colorPicker/colorPickerFrame.png b/designer_base/src/com/fr/design/images/gui/colorPicker/colorPickerFrame.png new file mode 100644 index 000000000..2772b7e20 Binary files /dev/null and b/designer_base/src/com/fr/design/images/gui/colorPicker/colorPickerFrame.png differ diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index accf7233d..f1c8fdc71 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -487,3 +487,9 @@ FR-Designer-LayerPageReport_PageQuery= FR-Designer-LayerPageReport_Define_PageQuerySQL= FR-Designer_Event= FR-Designer_Properties= +FR-Designer_Export_failed=Export failed +FR-Designer_Exported_successfully=Exported successfully +FR-Designer_Exporting=Exporting +FR-Designer_Export-PDF=PDF +FR-Designer_Button_OK=OK +FR-Designer_Button_Cancel=Cancel diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index 92f1cefbd..b4d693208 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -486,4 +486,10 @@ FR-Designer-DS-Database_Query=DB Query FR-Designer_Is_Share_DBTableData=Shared data set FR-Designer_Event=Event FR-Designer_Properties=Properties +FR-Designer_Export_failed=Export failed +FR-Designer_Exported_successfully=Exported successfully +FR-Designer_Exporting=Exporting +FR-Designer_Export-PDF=PDF FR-Designer_Properties_Mobile=MobileProperties +FR-Designer_Button_OK=OK +FR-Designer_Button_Cancel=Cancel diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index 80b139079..019970387 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -466,3 +466,9 @@ FR-Designer_Is_Share_DBTableData=\u5171\u6709\u30C7\u30FC\u30BF\u30BB\u30C3\u30C FR-Designer_Event=\ FR-Designer_Properties=FR-Designer_Properties=\ \ +FR-Designer_Export_failed=\u5C0E\u51FA\u306B\u5931\u6557\u3057\u307E\u3057\u305F +FR-Designer_Exported_successfully=\u5C0E\u51FA\u6210\u529F +FR-Designer_Exporting=\u5C0E\u51FA\u3057\u3066\u3044\u307E\u3059 +FR-Designer_Export-PDF=PDF\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8FR-Designer_Button_OK=FR-Designer_Button_OK=\u78BA\u5B9A +FR-Designer_Button_Cancel=\u30AD\u30E3\u30F3\u30BB\u30EB +\ \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index 41f2a987c..a84ff40a6 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -100,7 +100,7 @@ FR-Designer_FS_Close_Other_Templates=\uAE30\uD0C0\uD15C\uD50C\uB9BF\uB2EB\uAE30 FR-Designer_File=\uD30C\uC77C FR-Designer_Filter_Conditions=\uD544\uD130\uC870\uAC74 FR-Designer_Finish-Modify-Share=\uC218\uC815\uC644\uB8CC\uBC0F\uACF5\uC720 -FR-Designer_Fit=\uC790\uAE30\uC801\uC751 +FR-Designer_Fit-App=App\uC790\uAE30\uC801\uC751 FR-Designer_Font-Family=\uAE00\uAF34\uBA85\uCE6D FR-Designer_Font-Size=\uAE00\uAF34\uD06C\uAE30 FR-Designer_Forbid_Drag_into_Adapt_Pane=\uD574\uB2F9\uAC1D\uCCB4\uB294\uD3FC\uD14C\uC774\uBE14\uBC14\uB514\uB4DC\uB798\uADF8\uB97C\uD5C8\uC6A9\uD558\uC9C0\uC54A\uC2B5\uB2C8\uB2E4. @@ -460,4 +460,10 @@ FR-Designer_Is_Share_DBTableData=\uB370\uC774\uD130\uC138\uD2B8\uACF5\uC720 FR-Designer-LayerPageReport_PageQuery=\uD398\uC774\uC9C0\uB098\uB204\uAE30\uCC3E\uC544\uBCF4\uAE30 FR-Designer-LayerPageReport_Define_PageQuerySQL=\uC815\uC758\uD398\uC774\uC9C0\uB098\uB204\uAE30\uCC3E\uC544\uBCF4\uAE30sql FR-Designer_Event=\ -FR-Designer_Properties=\uFFFD \ No newline at end of file +FR-Designer_Properties=\uFFFD +FR-Designer_Export_failed=\uB0B4\uBCF4\uB0B4\uAE30\uC2E4\uD328 +FR-Designer_Exported_successfully=\uB0B4\uBCF4\uB0B4\uAE30\uC131\uACF5 +FR-Designer_Exporting=\uB0B4\uBCF4\uB0B4\uAE30\uC911 +FR-Designer_Export-PDF=PDF\uC11C\uC2DDFR-Designer_Properties=\uFFFD +FR-Designer_Button_OK=\uD655\uC778FR-Designer_Button_Cancel=\uCDE8\uC18C +\ \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index db7ac606c..77509989c 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -490,4 +490,10 @@ FR-Designer-LayerPageReport_Define_PageQuerySQL=\u5B9A\u4E49\u5206\u9875\u67E5\u FR-Designer_Is_Share_DBTableData=\u5171\u4EAB\u6570\u636E\u96C6 FR-Designer_Event=\u4E8B\u4EF6 FR-Designer_Properties=\u5C5E\u6027 +FR-Designer_Export_failed=\u5BFC\u51FA\u5931\u8D25 +FR-Designer_Exported_successfully=\u5BFC\u51FA\u6210\u529F +FR-Designer_Exporting=\u6B63\u5728\u5BFC\u51FA +FR-Designer_Export-PDF=PDF\u683C\u5F0F FR-Designer_Properties_Mobile=\u624B\u673A\u5C5E\u6027 +FR-Designer_Button_OK=\u786E\u5B9A +FR-Designer_Button_Cancel=\u53D6\u6D88 diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 9507840af..c9aac5cb3 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -478,4 +478,10 @@ FR-Designer-LayerPageReport_Define_PageQuerySQL=\u5B9A\u7FA9\u5206\u9801\u67E5\u FR-Designer_Is_Share_DBTableData=\u662F\u5426\u5171\u4EAB\u8CC7\u6599\u96C6 FR-Designer_Properties=\u5C6C\u6027 FR-Designer_Event=\u4E8B\u4EF6 +FR-Designer_Export_failed=\u532F\u51FA\u5931\u6557 +FR-Designer_Exported_successfully=\u532F\u51FA\u6210\u529F +FR-Designer_Exporting=\u6B63\u5728\u532F\u51FA... +FR-Designer_Export-PDF=PDF\u683C\u5F0F FR-Designer_Properties_Mobile=\u624B\u6A5F\u5C6C\u6027 +FR-Designer_Button_OK=\u78BA\u5B9A +FR-Designer_Button_Cancel=\u53D6\u6D88 \ No newline at end of file diff --git a/designer_base/src/com/fr/design/style/color/ColorPicker.java b/designer_base/src/com/fr/design/style/color/ColorPicker.java new file mode 100644 index 000000000..cb30c186d --- /dev/null +++ b/designer_base/src/com/fr/design/style/color/ColorPicker.java @@ -0,0 +1,202 @@ +package com.fr.design.style.color; + +/** + * Created by plough on 2016/12/22. + */ + +import com.fr.base.BaseUtils; + +import java.awt.*; +import java.awt.event.*; +import java.awt.geom.Ellipse2D; +import java.awt.image.BufferedImage; +import javax.swing.*; + +/** + * 取色框 + */ +public class ColorPicker extends JDialog implements ActionListener +{ + private Container container = getContentPane(); // 主容器 + private int setCoordinateX; // 取色框x坐标 + private int setCoordinateY; // 取色框y坐标 + private int colorPickerSize = 190; // 取色框尺寸 + private int scaleFactor = 16; // 放大倍数 + private ColorPickerPanel colorPickerPanel = new ColorPickerPanel(scaleFactor); // 取色框内容面板 + + private Timer timer; // 用于定时重绘 + private int FPS = 45; // 重绘取色器的频率 + private int timeCycle = 1000 / FPS; // 时钟周期 + + private ColorSelectable colorSelectable; + private Point mousePos; // 鼠标的绝对坐标 + private Color colorToSet; // 暂存要设置的颜色值 + + private Boolean setColorRealTime; // 实时设定颜色值 + + + /** + * 构造函数,创建一个取色框窗体 + */ + public ColorPicker(ColorSelectable colorSelectable, Boolean setColorRealTime) + { + setUndecorated(true); // 去掉窗体边缘 + setResizable(false); + Shape shape = new Ellipse2D.Double(0, 0, colorPickerSize, colorPickerSize); + setShape(shape); + container.add(colorPickerPanel); + addMouseListener(new MouseFunctions()); + updateSize(colorPickerSize); + this.colorSelectable = colorSelectable; + this.setColorRealTime = setColorRealTime; + this.setAlwaysOnTop(true); + this.setVisible(true); + this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + } + + public void start() { + timer = new Timer(timeCycle, this); + timer.start(); + hideCursor(); +// System.out.println(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow()); + } + + /** + * 执行Timer要执行的部分, + */ + @Override + public void actionPerformed(ActionEvent e) { + updateLocation(); + colorToSet = colorPickerPanel.getPixelColor(mousePos); + if (setColorRealTime && !colorSelectable.getColor().equals(colorToSet)) { + colorSelectable.setColor(colorToSet); + } + } + + public void updateLocation() { + mousePos = MouseInfo.getPointerInfo().getLocation(); + setCoordinateX = mousePos.x - getSize().width/2; + setCoordinateY = mousePos.y- getSize().height/2; + colorPickerPanel.setMagnifierLocation(setCoordinateX, + setCoordinateY); + setLocation(setCoordinateX, setCoordinateY); + } + + /** + * 更新窗体 + * + * @param colorPickerSize 取色框尺寸 + */ + public void updateSize(int colorPickerSize) + { + colorPickerPanel.setColorPickerSize(colorPickerSize); + setSize(colorPickerSize, colorPickerSize); + validate(); // 更新所有子控件 + } + + public void pickComplete() { + timer.stop(); + colorSelectable.setColor(colorToSet); + this.dispose(); + } + + // 隐藏鼠标光标 + public void hideCursor() { + Image imageCursor = Toolkit.getDefaultToolkit().getImage(""); + Cursor cu = Toolkit.getDefaultToolkit().createCustomCursor(imageCursor, new Point(0,0), "cursor"); + setCursor(cu); + } + + private class MouseFunctions extends MouseAdapter + { + public void mousePressed(MouseEvent e) + { + pickComplete(); + } + } +} + +class ColorPickerPanel extends JPanel +{ + private BufferedImage screenImage; + private Image colorPickerFrame; // 取色框的边框图案 + private int colorPickerSize; // 取色框尺寸 + private int locationX; // 取色框 x 坐标 + private int locationY; // 取色框 y 坐标 + private int scaleFactor; // 放大倍数 + private Robot robot; + + // getPixelColor 常数 + private static int SHIFT_STEP = 8; // 比特位右移步长 + private static int AND_R = 0xff0000; + private static int AND_G = 0xff00; + private static int AND_B = 0xff; + + /** + * 带参数的构造函数 + * @param scaleFactor 放大倍数 + */ + public ColorPickerPanel(int scaleFactor) + { + try + { + robot = new Robot(); + } + catch (AWTException e) + { + } + // 截屏幕 + 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; + } + + /** + * 设置取色框的位置 + * @param locationX x坐标 + * @param locationY y坐标 + */ + public void setMagnifierLocation(int locationX, int locationY) + { + this.locationX = locationX; + this.locationY = locationY; + repaint(); // 注意重画控件 + } + + public Color getPixelColor(Point mousePos) { + int rgb = screenImage.getRGB(mousePos.x, mousePos.y); + int R = (rgb & AND_R) >> SHIFT_STEP * 2; + int G = (rgb & AND_G) >> SHIFT_STEP; + int B = (rgb & AND_B); + return new Color(R, G, B); + } + + public void setColorPickerSize(int colorPickerSize) + { + this.colorPickerSize = colorPickerSize; + } + + public void paintComponent(Graphics g) + { + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); + + double pixelCount = (double)colorPickerSize / scaleFactor; // 取色器一条边上的放大后的像素点个数(可以是小数) + // 关键处理代码 + g2d.drawImage( + screenImage, // 要画的图片 + 0, // 目标矩形的第一个角的x坐标 + 0, // 目标矩形的第一个角的y坐标 + colorPickerSize, // 目标矩形的第二个角的x坐标 + colorPickerSize, // 目标矩形的第二个角的y坐标 + locationX + (int)((colorPickerSize - pixelCount) * 0.5) + 1, // 源矩形的第一个角的x坐标 + locationY + (int)((colorPickerSize - pixelCount) * 0.5) + 1, // 源矩形的第一个角的y坐标 + locationX + (int)((colorPickerSize + pixelCount) * 0.5) + 1, // 源矩形的第二个角的x坐标 + locationY + (int)((colorPickerSize + pixelCount) * 0.5) + 1, // 源矩形的第二个角的y坐标 + this + ); + g2d.drawImage(colorPickerFrame, 0, 0, this); + } +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/style/color/ColorSelectDialog.java b/designer_base/src/com/fr/design/style/color/ColorSelectDialog.java index bee4b07d2..a26bc10c2 100644 --- a/designer_base/src/com/fr/design/style/color/ColorSelectDialog.java +++ b/designer_base/src/com/fr/design/style/color/ColorSelectDialog.java @@ -91,8 +91,8 @@ public class ColorSelectDialog extends MiddleChartDialog{ this.add(buttonPane, BorderLayout.SOUTH); - ok = new UIButton(Inter.getLocText("OK")); - cancel = new UIButton(Inter.getLocText("Cancel")); + ok = new UIButton(Inter.getLocText("FR-Designer_Button_OK")); + cancel = new UIButton(Inter.getLocText("FR-Designer_Button_Cancel")); buttonPane.add(ok); buttonPane.add(cancel); @@ -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(); } diff --git a/designer_base/src/com/fr/design/style/color/ColorSelectPane.java b/designer_base/src/com/fr/design/style/color/ColorSelectPane.java index 7370bfff7..743a71ce4 100644 --- a/designer_base/src/com/fr/design/style/color/ColorSelectPane.java +++ b/designer_base/src/com/fr/design/style/color/ColorSelectPane.java @@ -3,10 +3,7 @@ */ package com.fr.design.style.color; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.GridLayout; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -71,10 +68,8 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable // center JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); this.add(centerPane, BorderLayout.CENTER); - - // 最近使用 - UsedColorPane pane = new UsedColorPane(1, 8, ColorSelectConfigManager.getInstance().getColors(),this); - centerPane.add(pane.getPane()); + + centerPane.add(getRow1Pane()); JPanel menuColorPane1 = new JPanel(); centerPane.add(menuColorPane1); @@ -104,6 +99,23 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable centerPane.add(centerPane1); } + // 第一行,1个取色按钮 + 7个最近使用的颜色 + private JPanel getRow1Pane() { + JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout()); + row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0)); + row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7 + + // 取色按钮 + UIButton pickColorButton = PickColorButtonFactory.getPickColorButton(this, PickColorButtonFactory.IconType.ICON16, true); + row1Pane.add(pickColorButton, BorderLayout.WEST); + + // 最近使用 + UsedColorPane usedColorPane = new UsedColorPane(1, 7, ColorSelectConfigManager.getInstance().getColors(),this); + usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 8)); + row1Pane.add(usedColorPane.getPane()); + return row1Pane; + } + protected Color[] getColorArray(){ return ColorFactory.MenuColors; } diff --git a/designer_base/src/com/fr/design/style/color/CustomChooserPanel.java b/designer_base/src/com/fr/design/style/color/CustomChooserPanel.java index 179e90abe..85363b0e6 100644 --- a/designer_base/src/com/fr/design/style/color/CustomChooserPanel.java +++ b/designer_base/src/com/fr/design/style/color/CustomChooserPanel.java @@ -10,9 +10,7 @@ import java.awt.Graphics; import java.awt.GridLayout; import java.awt.Image; import java.awt.Point; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionListener; +import java.awt.event.*; import java.awt.image.MemoryImageSource; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -21,7 +19,6 @@ import javax.swing.ButtonGroup; import javax.swing.Icon; import javax.swing.JColorChooser; import javax.swing.JPanel; -import javax.swing.JSlider; import javax.swing.SpinnerNumberModel; import javax.swing.SwingConstants; import javax.swing.colorchooser.AbstractColorChooserPanel; @@ -32,6 +29,7 @@ import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; import javax.swing.text.Document; +import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.islider.UISlider; @@ -42,1031 +40,1039 @@ import com.fr.general.Inter; /** * 颜色选择器自定义面板 - * @author focus * + * @author focus */ -class CustomChooserPanel extends AbstractColorChooserPanel -{ - /** The gradient image displayed. */ - private transient Image gradientImage; +class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelectable { + /** + * The gradient image displayed. + */ + private transient Image gradientImage; - /** The Panel that holds the gradient image. */ - private transient JPanel gradientPanel; + /** + * The Panel that holds the gradient image. + */ + private transient JPanel gradientPanel; - /** The track gradient image. */ - private transient Image trackImage; + /** + * The track gradient image. + */ + private transient Image trackImage; - /** The panel that holds the track. */ - private transient JPanel trackPanel; + /** + * The panel that holds the track. + */ + private transient JPanel trackPanel; - /** The slider for the locked HSB value. */ - private transient UISlider slider; - - /** The RadioButton that controls the Hue. */ - private transient UIRadioButton hRadio; - - /** The RadioButton that controls the Saturation. */ - private transient UIRadioButton sRadio; - - /** The RadioButton that controls the Brightness. */ - private transient UIRadioButton bRadio; - - /** The UIBasicSpinner that controls the Hue. */ - private transient UIBasicSpinner hSpinner; - - /** The UIBasicSpinner that controls the Saturation. */ - private transient UIBasicSpinner sSpinner; - - /** The UIBasicSpinner that controls the Brightness. */ - private transient UIBasicSpinner bSpinner; - - /** The UIBasicSpinner that controls the Red. */ - private transient UIBasicSpinner rSpinner; - - /** The UIBasicSpinner that controls the Green. */ - private transient UIBasicSpinner gSpinner; - - /** The UIBasicSpinner that controls the Blue. */ - private transient UIBasicSpinner bbSpinner; - - private transient UITextField field; - - - /** The default width of the gradient image. */ - private static final int IMG_WIDTH = 200; - - /** The default height of the gradient image. */ - private static final int IMG_HEIGHT = 205; - - /** The default width of the track gradient. */ - private static final int TRACK_WIDTH = 20; - - /** The UILabel for Red. */ - private static final UILabel R = new UILabel("R"); - - /** The UILabel for Green. */ - private static final UILabel G = new UILabel("G"); - - /** The UILabel for Blue. */ - private static final UILabel B = new UILabel("B"); - - private static final int H_MAX = 365; - private static final int S_MAX = 100; - private static final int L_MAX = 100; - - private static final float HSPINNER_VALUE = 360f; - private static final float SSPINNER_VALUE = 100f; - private static final float LSPINNER_VALUE = 100f; - - private static final int BINARY_FOR_EIGHT = 255; - private static final int BINARY_FOR_FOUR = 16; - private static final int BINARY_FOR_THTEE = 8; - - private static final int TWENTY_FOUR = 24; - private static final int HEX_FF = 0xff; - - // 占位label - private static final UILabel PLACE_HOLDER_LABEL = new UILabel(); - - private ImageRGBScrollListener rgbScroll = new ImageRGBScrollListener(); - - - /** The point that is displayed in the gradient image. */ - private transient Point gradientPoint = new Point(); - - /** - * This indicates that the change to the slider or point is triggered - * internally. - */ - private transient boolean internalChange = false; - - /** This indicates that the change to the spinner is triggered internally. */ - private transient boolean spinnerTrigger = false; - - /** This int identifies which spinner is currently locked. */ - private transient int locked = -1; - - /** This value indicates that the Hue spinner is locked. */ - static final int HLOCKED = 0; - - /** This value indicates that the Saturation spinner is locked. */ - static final int SLOCKED = 1; - - /** This value indicates that the Brightness spinner is locked. */ - static final int BLOCKED = 2; - - /** - * This method indicates that the mouse event is in the process of being - * handled. - */ - private transient boolean handlingMouse; - - // 文本监听器,监听十六进制文本输入 - class TextDocumentListener implements DocumentListener{ - - // 十六进制颜色验证的正则表达式 - private static final String HEX_PATTERN = "([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"; - private Pattern pattern; - private Matcher matcher; - @Override - public void insertUpdate(DocumentEvent e) { - Document doc = e.getDocument(); - updateColorForHex(doc); - } - - @Override - public void removeUpdate(DocumentEvent e) { - Document doc = e.getDocument(); - updateColorForHex(doc); - } - - @Override - public void changedUpdate(DocumentEvent e) { - - } - - private void updateColorForHex(Document doc){ - try { - String str = doc.getText(0, doc.getLength()); - pattern = Pattern.compile(HEX_PATTERN); - matcher = pattern.matcher(str); - if(matcher.matches()){ - Color color = new Color(Integer.parseInt(str, 16)); - CustomChooserPanel.this.getColorSelectionModel().setSelectedColor(color); - } - - } catch (BadLocationException e1) { - FRLogger.getLogger().error(e1.getMessage()); - } - } - } - - /** - * This helper class handles mouse events on the gradient image. - */ - class MainGradientMouseListener extends MouseAdapter - implements MouseMotionListener - { /** - * This method is called when the mouse is pressed over the gradient - * image. The JColorChooser is then updated with new HSB values. - * - * @param e The MouseEvent. + * The slider for the locked HSB value. + */ + private transient UISlider slider; + + /** + * The RadioButton that controls the Hue. + */ + private transient UIRadioButton hRadio; + + /** + * The RadioButton that controls the Saturation. + */ + private transient UIRadioButton sRadio; + + /** + * The RadioButton that controls the Brightness. + */ + private transient UIRadioButton bRadio; + + /** + * The UIBasicSpinner that controls the Hue. + */ + private transient UIBasicSpinner hSpinner; + + /** + * The UIBasicSpinner that controls the Saturation. + */ + private transient UIBasicSpinner sSpinner; + + /** + * The UIBasicSpinner that controls the Brightness. */ - public void mousePressed(MouseEvent e) - { - gradientPoint = e.getPoint(); - update(e.getPoint()); + private transient UIBasicSpinner bSpinner; + + /** + * The UIBasicSpinner that controls the Red. + */ + private transient UIBasicSpinner rSpinner; + + /** + * The UIBasicSpinner that controls the Green. + */ + private transient UIBasicSpinner gSpinner; + + /** + * The UIBasicSpinner that controls the Blue. + */ + private transient UIBasicSpinner bbSpinner; + + private transient UITextField field; + +// private transient PickColorButton pickColorButton; + + + /** + * The default width of the gradient image. + */ + private static final int IMG_WIDTH = 200; + + /** + * The default height of the gradient image. + */ + private static final int IMG_HEIGHT = 205; + + /** + * The default width of the track gradient. + */ + private static final int TRACK_WIDTH = 20; + + /** + * The UILabel for Red. + */ + private static final UILabel R = new UILabel("R"); + + /** + * The UILabel for Green. + */ + private static final UILabel G = new UILabel("G"); + + /** + * The UILabel for Blue. + */ + private static final UILabel B = new UILabel("B"); + + private static final int H_MAX = 365; + private static final int S_MAX = 100; + private static final int L_MAX = 100; + + private static final float HSPINNER_VALUE = 360f; + private static final float SSPINNER_VALUE = 100f; + private static final float LSPINNER_VALUE = 100f; + + private static final int BINARY_FOR_EIGHT = 255; + private static final int BINARY_FOR_FOUR = 16; + private static final int BINARY_FOR_THTEE = 8; + + private static final int TWENTY_FOUR = 24; + private static final int HEX_FF = 0xff; + + // 占位label + private static final UILabel PLACE_HOLDER_LABEL = new UILabel(); + + private ImageRGBScrollListener rgbScroll = new ImageRGBScrollListener(); + + + /** + * The point that is displayed in the gradient image. + */ + private transient Point gradientPoint = new Point(); + + /** + * This indicates that the change to the slider or point is triggered + * internally. + */ + private transient boolean internalChange = false; + + /** + * This indicates that the change to the spinner is triggered internally. + */ + private transient boolean spinnerTrigger = false; + + /** + * This int identifies which spinner is currently locked. + */ + private transient int locked = -1; + + /** + * This value indicates that the Hue spinner is locked. + */ + static final int HLOCKED = 0; + + /** + * This value indicates that the Saturation spinner is locked. + */ + static final int SLOCKED = 1; + + /** + * This value indicates that the Brightness spinner is locked. + */ + static final int BLOCKED = 2; + + /** + * This method indicates that the mouse event is in the process of being + * handled. + */ + private transient boolean handlingMouse; + + // 文本监听器,监听十六进制文本输入 + class TextDocumentListener implements DocumentListener { + + // 十六进制颜色验证的正则表达式 + private static final String HEX_PATTERN = "([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"; + private Pattern pattern; + private Matcher matcher; + + @Override + public void insertUpdate(DocumentEvent e) { + Document doc = e.getDocument(); + updateColorForHex(doc); + } + + @Override + public void removeUpdate(DocumentEvent e) { + Document doc = e.getDocument(); + updateColorForHex(doc); + } + + @Override + public void changedUpdate(DocumentEvent e) { + + } + + private void updateColorForHex(Document doc) { + try { + String str = doc.getText(0, doc.getLength()); + pattern = Pattern.compile(HEX_PATTERN); + matcher = pattern.matcher(str); + if (matcher.matches()) { + Color color = new Color(Integer.parseInt(str, 16)); + CustomChooserPanel.this.getColorSelectionModel().setSelectedColor(color); + } + + } catch (BadLocationException e1) { + FRLogger.getLogger().error(e1.getMessage()); + } + } } /** - * This method is called when the mouse is dragged over the gradient - * image. The JColorChooser is then updated with the new HSB values. - * - * @param e The MouseEvent. + * This helper class handles mouse events on the gradient image. */ - public void mouseDragged(MouseEvent e) - { - Point p = e.getPoint(); - if (isMouseOutOfImage(p)){ - return; - } - - gradientPoint = p; - update(p); + class MainGradientMouseListener extends MouseAdapter + implements MouseMotionListener { + /** + * This method is called when the mouse is pressed over the gradient + * image. The JColorChooser is then updated with new HSB values. + * + * @param e The MouseEvent. + */ + public void mousePressed(MouseEvent e) { + gradientPoint = e.getPoint(); + update(e.getPoint()); + } + + /** + * This method is called when the mouse is dragged over the gradient + * image. The JColorChooser is then updated with the new HSB values. + * + * @param e The MouseEvent. + */ + public void mouseDragged(MouseEvent e) { + Point p = e.getPoint(); + if (isMouseOutOfImage(p)) { + return; + } + + gradientPoint = p; + update(p); + } + + private boolean isMouseOutOfImage(Point p) { + return (p.x < 0 || p.y < 0 || p.y > IMG_HEIGHT || p.x > IMG_WIDTH); + } + + /** + * This method is called when the mouse is moved over the gradient image. + * + * @param e The MouseEvent. + */ + public void mouseMoved(MouseEvent e) { + // Do nothing. + } + + /** + * This method updates the JColorChooser with the new values. + * + * @param p The Point where the MouseEvent occurred. + */ + private void update(Point p) { + handlingMouse = true; + if (hSpinner.isEnabled()) { + updateH(p); + } else if (sSpinner.isEnabled()) { + updateS(p); + } else { + updateB(p); + } + handlingMouse = false; + } + + /** + * This method updates the SB values if Hue is locked. + * + * @param p The point where the MouseEvent occurred. + */ + private void updateH(Point p) { + float s = (IMG_WIDTH - p.x * 1f) / IMG_WIDTH; + float b = (IMG_HEIGHT - p.y * 1f) / IMG_HEIGHT; + + // Avoid two changes to the model by changing internalChange to true. + internalChange = true; + sSpinner.setValue(new Integer((int) (s * S_MAX))); + internalChange = false; + bSpinner.setValue(new Integer((int) (b * L_MAX))); + + revalidate(); + } + + /** + * This method updates the HB values if Saturation is locked. + * + * @param p The point where the MouseEvent occurred. + */ + private void updateS(Point p) { + float h = p.x * 1f / IMG_WIDTH; + float b = (IMG_HEIGHT - p.y * 1f) / IMG_HEIGHT; + + internalChange = true; + hSpinner.setValue(new Integer((int) (h * H_MAX))); + internalChange = false; + bSpinner.setValue(new Integer((int) (b * L_MAX))); + + revalidate(); + } + + /** + * This method updates the HS values if Brightness is locked. + * + * @param p The point where the MouseEvent occurred. + */ + private void updateB(Point p) { + float h = p.x * 1f / IMG_WIDTH; + float s = (IMG_HEIGHT - p.y * 1f) / IMG_HEIGHT; + + internalChange = true; + hSpinner.setValue(new Integer((int) (h * H_MAX))); + internalChange = false; + sSpinner.setValue(new Integer((int) (s * S_MAX))); + + revalidate(); + } } - - private boolean isMouseOutOfImage(Point p){ - return (p.x < 0 || p.y < 0 || p.y > IMG_HEIGHT || p.x > IMG_WIDTH); + + /** + * This method listens for slider value changes. + */ + class SliderChangeListener implements ChangeListener { + /** + * This method is called when the slider value changes. It should change + * the color of the JColorChooser. + * + * @param e The ChangeEvent. + */ + public void stateChanged(ChangeEvent e) { + if (internalChange) { + return; + } + + + Integer value = new Integer(slider.getValue()); + + switch (locked) { + case HLOCKED: + hSpinner.setValue(value); + break; + case SLOCKED: + sSpinner.setValue(value); + break; + case BLOCKED: + bSpinner.setValue(value); + break; + } + updateImageAndTrack(); + } } /** - * This method is called when the mouse is moved over the gradient image. - * - * @param e The MouseEvent. + * This helper class determines the active UIBasicSpinner. */ - public void mouseMoved(MouseEvent e) - { - // Do nothing. + class RadioStateListener extends MouseAdapter + implements MouseMotionListener { + /** + * This method is called when there is a new UIRadioButton that was + * selected. As a result, it should activate the associated UIBasicSpinner. + * + * @param e The ChangeEvent. + */ + public void mousePressed(MouseEvent e) { + UIBasicSpinner change; + if (e.getSource() == hRadio) { + locked = HLOCKED; + change = hSpinner; + } else if (e.getSource() == sRadio) { + locked = SLOCKED; + change = sSpinner; + } else { + locked = BLOCKED; + change = bSpinner; + } + + hSpinner.setEnabled(false); + sSpinner.setEnabled(false); + bSpinner.setEnabled(false); + change.setEnabled(true); + updateSlider(); + updateTrack(); + updateImage(); + repaint(); + + } } /** - * This method updates the JColorChooser with the new values. - * - * @param p The Point where the MouseEvent occurred. + * hsl 监听 */ - private void update(Point p) - { - handlingMouse = true; - if (hSpinner.isEnabled()){ - updateH(p); - }else if (sSpinner.isEnabled()){ - updateS(p); - }else{ - updateB(p); - } - handlingMouse = false; + class ImageScrollListener implements ChangeListener { + /** + * This method is called whenever one of the UIBasicSpinner values change. The + * JColorChooser should be updated with the new HSB values. + * + * @param e The ChangeEvent. + */ + public void stateChanged(ChangeEvent e) { + if (internalChange) { + return; + } + updateImageAndTrack(); + updateSlider(); + } } /** - * This method updates the SB values if Hue is locked. - * - * @param p The point where the MouseEvent occurred. + * rgb 监听 */ - private void updateH(Point p) - { - float s = (IMG_WIDTH - p.x * 1f) / IMG_WIDTH; - float b = (IMG_HEIGHT - p.y * 1f) / IMG_HEIGHT; - - // Avoid two changes to the model by changing internalChange to true. - internalChange = true; - sSpinner.setValue(new Integer((int) (s * S_MAX))); - internalChange = false; - bSpinner.setValue(new Integer((int) (b * L_MAX))); - - revalidate(); + class ImageRGBScrollListener implements ChangeListener { + /** + * This method is called whenever one of the UIBasicSpinner values change. The + * JColorChooser should be updated with the new HSB values. + * + * @param e The ChangeEvent. + */ + public void stateChanged(ChangeEvent e) { + if (internalChange) { + return; + } + + + int r = (Integer) rSpinner.getValue(); + int g = (Integer) gSpinner.getValue(); + int bb = (Integer) bbSpinner.getValue(); + + spinnerTrigger = true; + getColorSelectionModel().setSelectedColor(new Color(r, g, bb)); + spinnerTrigger = false; + + updateChooser(); + repaint(); + } } /** - * This method updates the HB values if Saturation is locked. + * Creates a new DefaultHSBChooserPanel object. + */ + CustomChooserPanel() { + super(); + } + + /** + * This method returns the name displayed by the JColorChooser tab that + * holds this panel. * - * @param p The point where the MouseEvent occurred. + * @return The name displayed in the JColorChooser tab. */ - private void updateS(Point p) - { - float h = p.x * 1f / IMG_WIDTH; - float b = (IMG_HEIGHT - p.y * 1f) / IMG_HEIGHT; + public String getDisplayName() { + return Inter.getLocText("FR-Designer_Custom"); + } + + /** + * This method updates the various components inside the HSBPanel (the + * UIBasicSpinners, the JSlider, and the gradient image point) with updated + * values when the JColorChooser color value changes. + */ + public void updateChooser() { + Color c = getColorSelectionModel().getSelectedColor(); + float[] hsbVals = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), + null); + internalChange = true; + + adjustHSLValue(hsbVals); - internalChange = true; - hSpinner.setValue(new Integer((int) (h * H_MAX))); - internalChange = false; - bSpinner.setValue(new Integer((int) (b * L_MAX))); + internalChange = false; - revalidate(); + if (!handlingMouse && slider != null && !slider.getValueIsAdjusting()) { + updateImage(); + } + + if (!handlingMouse || locked != HLOCKED) { + updateTrack(); + } + updateTextFields(); + updateHexFields(); + } + + private void adjustHSLValue(float[] hsbVals) { + if (!spinnerTrigger) { + hSpinner.setValue(new Integer((int) (hsbVals[0] * HSPINNER_VALUE))); + sSpinner.setValue(new Integer((int) (hsbVals[1] * SSPINNER_VALUE))); + bSpinner.setValue(new Integer((int) (hsbVals[2] * LSPINNER_VALUE))); + } + switch (locked) { + case HLOCKED: + if (slider != null) { + slider.setValue(((Number) hSpinner.getValue()).intValue()); + } + if (!handlingMouse) { + gradientPoint.x = (int) ((1 + - ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE) * IMG_WIDTH); + gradientPoint.y = (int) ((1 + - ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE) * IMG_HEIGHT); + } + break; + case SLOCKED: + if (slider != null) { + slider.setValue(((Number) sSpinner.getValue()).intValue()); + } + if (!handlingMouse) { + gradientPoint.x = (int) (((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE * IMG_WIDTH); + gradientPoint.y = (int) ((1 + - ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE) * IMG_HEIGHT); + } + break; + case BLOCKED: + if (slider != null) { + slider.setValue(((Number) bSpinner.getValue()).intValue()); + } + if (!handlingMouse) { + gradientPoint.x = (int) (((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE * IMG_WIDTH); + gradientPoint.y = (int) ((1 + - ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE) * IMG_HEIGHT); + } + break; + } + } + + private void updateImageAndTrack() { + float h = ((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE; + float s = ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE; + float b = ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE; + + spinnerTrigger = true; + getColorSelectionModel().setSelectedColor(new Color(Color.HSBtoRGB(h, s, b))); + spinnerTrigger = false; + + if (!handlingMouse && slider != null && !slider.getValueIsAdjusting()) { + updateImage(); + updateTrack(); + } + updateTextFields(); + updateHexFields(); + repaint(); } /** - * This method updates the HS values if Brightness is locked. - * - * @param p The point where the MouseEvent occurred. + * This method builds the DefaultHSBChooserPanel. */ - private void updateB(Point p) - { - float h = p.x * 1f / IMG_WIDTH; - float s = (IMG_HEIGHT - p.y * 1f) / IMG_HEIGHT; + protected void buildChooser() { + setLayout(new BorderLayout()); + add(buildRightPanel(), BorderLayout.EAST); + JPanel container = new JPanel(); + container.setLayout(new BorderLayout()); + + gradientPanel = createGradientPanel(); + MouseAdapter ml = new MainGradientMouseListener(); + gradientPanel.addMouseListener(ml); + gradientPanel.addMouseMotionListener((MouseMotionListener) ml); + + trackPanel = createTrackPanel(); + + slider = new UISlider(); + slider.setPaintTrack(false); + slider.setPaintTicks(false); + + slider.setOrientation(SwingConstants.VERTICAL); + + updateSlider(); + + container.add(gradientPanel, BorderLayout.WEST); + container.add(slider, BorderLayout.CENTER); + container.add(trackPanel, BorderLayout.EAST); - internalChange = true; - hSpinner.setValue(new Integer((int) (h * H_MAX))); - internalChange = false; - sSpinner.setValue(new Integer((int) (s * S_MAX))); + add(container, BorderLayout.WEST); + slider.addChangeListener(new SliderChangeListener()); - revalidate(); + updateTextFields(); + updateHexFields(); + repaint(); + } + + private JPanel createGradientPanel() { + return new JPanel() { + public Dimension getPreferredSize() { + return new Dimension(IMG_WIDTH, IMG_HEIGHT); + } + + public void paint(Graphics g) { + if (gradientImage != null) { + g.drawImage(gradientImage, 0, 0, this); + } + + Color saved = g.getColor(); + g.setColor(Color.WHITE); + g.drawOval(gradientPoint.x - 3, gradientPoint.y - 3, 6, 6); + g.setColor(saved); + } + }; + } + + private JPanel createTrackPanel() { + return new JPanel() { + public Dimension getPreferredSize() { + return new Dimension(TRACK_WIDTH, IMG_HEIGHT); + } + + public void paint(Graphics g) { + if (trackImage != null) { + g.drawImage(trackImage, 0, 0, this); + } + + } + }; } - } - /** - * This method listens for slider value changes. - */ - class SliderChangeListener implements ChangeListener - { /** - * This method is called when the slider value changes. It should change - * the color of the JColorChooser. + * This method uninstalls the DefaultHSBPanel. * - * @param e The ChangeEvent. + * @param chooser The JColorChooser to remove this panel from. */ - public void stateChanged(ChangeEvent e) - { - if (internalChange){ - return; - } - - - Integer value = new Integer(slider.getValue()); - - switch (locked) - { - case HLOCKED: - hSpinner.setValue(value); - break; - case SLOCKED: - sSpinner.setValue(value); - break; - case BLOCKED: - bSpinner.setValue(value); - break; - } - updateImageAndTrack(); + public void uninstallChooserPanel(JColorChooser chooser) { + trackImage = null; + gradientImage = null; + gradientPanel = null; + slider = null; + + hSpinner = null; + sSpinner = null; + bSpinner = null; + + hRadio = null; + sRadio = null; + bRadio = null; + + removeAll(); + super.uninstallChooserPanel(chooser); } - } - - /** - * This helper class determines the active UIBasicSpinner. - */ - class RadioStateListener extends MouseAdapter - implements MouseMotionListener - { + /** - * This method is called when there is a new UIRadioButton that was - * selected. As a result, it should activate the associated UIBasicSpinner. + * This helper method creates the right side panel (the panel with the + * Spinners and TextFields). * - * @param e The ChangeEvent. + * @return The right side panel. */ - public void mousePressed(MouseEvent e) - { - UIBasicSpinner change; - if (e.getSource() == hRadio) - { - locked = HLOCKED; - change = hSpinner; - } - else if (e.getSource() == sRadio) - { - locked = SLOCKED; - change = sSpinner; - } - else - { - locked = BLOCKED; - change = bSpinner; - } - - hSpinner.setEnabled(false); + private Container buildRightPanel() { + JPanel container = new JPanel(); + container.setLayout(new FlowLayout(FlowLayout.RIGHT)); + + // 主面板 + JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new BorderLayout(0, 10)); + UILabel label = new UILabel(); + label.setSize(200, 200); + container.add(label); + container.add(mainPanel); + + // hsl和rgb面板 + JPanel hslAndRgbPanel = new JPanel(); + hslAndRgbPanel.setLayout(new BorderLayout(0, 16)); + hslAndRgbPanel.add(initialHSLPanel(), BorderLayout.CENTER); + hslAndRgbPanel.add(initialRGBPanel(), BorderLayout.SOUTH); + + // 十六进制面板 + JPanel hexPanel = new JPanel(); + hexPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 8, 0)); + hexPanel.add(new UILabel("#")); + hexPanel.add(field); + UIButton pickColorButton = PickColorButtonFactory.getPickColorButton(this, PickColorButtonFactory.IconType.ICON18, true); + hexPanel.add(pickColorButton); + + mainPanel.add(hslAndRgbPanel, BorderLayout.CENTER); + mainPanel.add(hexPanel, BorderLayout.SOUTH); + + return container; + } + + //初始化HSL部分 + private JPanel initialHSLPanel() { + hRadio = new UIRadioButton("H"); + sRadio = new UIRadioButton("S"); + bRadio = new UIRadioButton("L"); + ButtonGroup group = new ButtonGroup(); + group.add(hRadio); + group.add(sRadio); + group.add(bRadio); + + hSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 359, 1)); + sSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 100, 1)); + bSpinner = new UIBasicSpinner(new SpinnerNumberModel(100, 0, 100, 1)); + hSpinner.setEnabled(true); sSpinner.setEnabled(false); bSpinner.setEnabled(false); - change.setEnabled(true); - updateSlider(); - updateTrack(); - updateImage(); - repaint(); - + + MouseAdapter cl = new RadioStateListener(); + locked = HLOCKED; + hRadio.setSelected(true); + hRadio.addMouseListener(cl); + sRadio.addMouseListener(cl); + bRadio.addMouseListener(cl); + + ChangeListener scroll = new ImageScrollListener(); + hSpinner.addChangeListener(scroll); + sSpinner.addChangeListener(scroll); + bSpinner.addChangeListener(scroll); + + JPanel hslPanel = new JPanel(); + hslPanel.setLayout(new GridLayout(3, 0, 0, 5)); + + JPanel hPanel = new JPanel(); + hPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); + hPanel.add(hRadio); + hPanel.add(hSpinner); + hslPanel.add(hPanel); + + JPanel sPanel = new JPanel(); + sPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); + sPanel.add(sRadio); + sPanel.add(sSpinner); + hslPanel.add(sPanel); + + JPanel lPanel = new JPanel(); + lPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); + lPanel.add(bRadio); + lPanel.add(bSpinner); + hslPanel.add(lPanel); + return hslPanel; + } + + private JPanel initialRGBPanel() { + // 初始化RGB部分 + rSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 255, 1)); + gSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 255, 1)); + bbSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 255, 1)); + + rSpinner.setEnabled(true); + gSpinner.setEnabled(true); + bbSpinner.setEnabled(true); + + addRGBSpinnerChangeLisener(); + + TextDocumentListener listen = new TextDocumentListener(); + field = new UITextField(); + field.setPreferredSize(new Dimension(70, 18)); + field.getDocument().addDocumentListener(listen); + + JPanel rgbPanel = new JPanel(); + rgbPanel.setLayout(new GridLayout(3, 0, 0, 5)); + + JPanel rPanel = new JPanel(); + rPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); + rPanel.add(R); + rPanel.add(rSpinner); + rgbPanel.add(rPanel); + + JPanel gPanel = new JPanel(); + gPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); + gPanel.add(G); + gPanel.add(gSpinner); + rgbPanel.add(gPanel); + + JPanel bPanel = new JPanel(); + bPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); + bPanel.add(B); + bPanel.add(bbSpinner); + rgbPanel.add(bPanel); + + return rgbPanel; } - } - /** - * hsl 监听 - */ - class ImageScrollListener implements ChangeListener - { /** - * This method is called whenever one of the UIBasicSpinner values change. The - * JColorChooser should be updated with the new HSB values. + * This method returns the small display icon. * - * @param e The ChangeEvent. + * @return The small display icon. */ - public void stateChanged(ChangeEvent e) - { - if (internalChange){ - return; - } - updateImageAndTrack(); - updateSlider(); + public Icon getSmallDisplayIcon() { + return null; } - } - - /** - * rgb 监听 - */ - class ImageRGBScrollListener implements ChangeListener - { + /** - * This method is called whenever one of the UIBasicSpinner values change. The - * JColorChooser should be updated with the new HSB values. + * This method returns the large display icon. * - * @param e The ChangeEvent. + * @return The large display icon. */ - public void stateChanged(ChangeEvent e) - { - if (internalChange){ - return; - } - - - int r = (Integer) rSpinner.getValue(); - int g = (Integer) gSpinner.getValue(); - int bb = (Integer) bbSpinner.getValue(); - - spinnerTrigger = true; - getColorSelectionModel().setSelectedColor(new Color(r,g,bb)); - spinnerTrigger = false; - - updateChooser(); - repaint(); - } - } - - /** - * Creates a new DefaultHSBChooserPanel object. - */ - CustomChooserPanel() - { - super(); - } - - /** - * This method returns the name displayed by the JColorChooser tab that - * holds this panel. - * - * @return The name displayed in the JColorChooser tab. - */ - public String getDisplayName() - { - return Inter.getLocText("FR-Designer_Custom"); - } - - /** - * This method updates the various components inside the HSBPanel (the - * UIBasicSpinners, the JSlider, and the gradient image point) with updated - * values when the JColorChooser color value changes. - */ - public void updateChooser() - { - Color c = getColorSelectionModel().getSelectedColor(); - float[] hsbVals = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), - null); - internalChange = true; - - adjustHSLValue(hsbVals); - - internalChange = false; - - if (! handlingMouse && slider != null && ! slider.getValueIsAdjusting()){ - updateImage(); + public Icon getLargeDisplayIcon() { + return null; } - if (! handlingMouse || locked != HLOCKED){ - updateTrack(); + /** + * This method updates the gradient image with a new one taking the Hue + * value as the constant. + */ + private void updateHLockImage() { + int index = 0; + int[] pix = new int[IMG_WIDTH * IMG_HEIGHT]; + float hValue = ((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE; + + for (int j = 0; j < IMG_HEIGHT; j++) { + for (int i = 0; i < IMG_WIDTH; i++) { + pix[index++] = Color.HSBtoRGB(hValue, (IMG_WIDTH - i * 1f) / IMG_WIDTH, + (IMG_HEIGHT - j * 1f) / IMG_HEIGHT) | (BINARY_FOR_EIGHT << TWENTY_FOUR); + } + } + + gradientImage = createImage(new MemoryImageSource(IMG_WIDTH, IMG_HEIGHT, + pix, 0, IMG_WIDTH)); } - updateTextFields(); - updateHexFields(); - } - - private void adjustHSLValue(float[] hsbVals){ - if (! spinnerTrigger) - { - hSpinner.setValue(new Integer((int) (hsbVals[0] * HSPINNER_VALUE))); - sSpinner.setValue(new Integer((int) (hsbVals[1] * SSPINNER_VALUE))); - bSpinner.setValue(new Integer((int) (hsbVals[2] * LSPINNER_VALUE))); - } - switch (locked) - { - case HLOCKED: - if (slider != null){ - slider.setValue(((Number) hSpinner.getValue()).intValue()); - } - if (! handlingMouse) - { - gradientPoint.x = (int) ((1 - - ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE) * IMG_WIDTH); - gradientPoint.y = (int) ((1 - - ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE) * IMG_HEIGHT); - } - break; - case SLOCKED: - if (slider != null){ - slider.setValue(((Number) sSpinner.getValue()).intValue()); - } - if (! handlingMouse) - { - gradientPoint.x = (int) (((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE * IMG_WIDTH); - gradientPoint.y = (int) ((1 - - ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE) * IMG_HEIGHT); - } - break; - case BLOCKED: - if (slider != null){ - slider.setValue(((Number) bSpinner.getValue()).intValue()); - } - if (! handlingMouse) - { - gradientPoint.x = (int) (((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE * IMG_WIDTH); - gradientPoint.y = (int) ((1 - - ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE) * IMG_HEIGHT); - } - break; - } - } - - private void updateImageAndTrack(){ - float h = ((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE; - float s = ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE; - float b = ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE; - - spinnerTrigger = true; - getColorSelectionModel().setSelectedColor(new Color(Color.HSBtoRGB(h, s, b))); - spinnerTrigger = false; - - if (! handlingMouse && slider != null && ! slider.getValueIsAdjusting()) - { - updateImage(); - updateTrack(); + + /** + * This method updates the gradient image with a new one taking the + * Brightness value as the constant. + */ + private void updateBLockImage() { + int[] pix = new int[IMG_WIDTH * IMG_HEIGHT]; + float bValue = ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE; + + int index = 0; + for (int j = 0; j < IMG_HEIGHT; j++) { + for (int i = 0; i < IMG_WIDTH; i++) { + pix[index++] = Color.HSBtoRGB(i * 1f / IMG_WIDTH, + (IMG_HEIGHT - j * 1f) / IMG_HEIGHT, bValue) | (BINARY_FOR_EIGHT << TWENTY_FOUR); + } } - updateTextFields(); - updateHexFields(); - repaint(); - } - - /** - * This method builds the DefaultHSBChooserPanel. - */ - protected void buildChooser() - { - setLayout(new BorderLayout()); - add(buildRightPanel(), BorderLayout.EAST); - JPanel container = new JPanel(); - container.setLayout(new BorderLayout()); - - gradientPanel = createGradientPanel(); - MouseAdapter ml = new MainGradientMouseListener(); - gradientPanel.addMouseListener(ml); - gradientPanel.addMouseMotionListener((MouseMotionListener) ml); - - trackPanel = createTrackPanel(); - - slider = new UISlider(); - slider.setPaintTrack(false); - slider.setPaintTicks(false); - - slider.setOrientation(SwingConstants.VERTICAL); - - updateSlider(); - - container.add(gradientPanel, BorderLayout.WEST); - container.add(slider, BorderLayout.CENTER); - container.add(trackPanel, BorderLayout.EAST); - - add(container, BorderLayout.WEST); - slider.addChangeListener(new SliderChangeListener()); - - updateTextFields(); - updateHexFields(); - repaint(); - } - - private JPanel createGradientPanel(){ - return new JPanel() - { - public Dimension getPreferredSize() - { - return new Dimension(IMG_WIDTH, IMG_HEIGHT); - } - - public void paint(Graphics g) - { - if (gradientImage != null){ - g.drawImage(gradientImage, 0, 0, this); - } - - Color saved = g.getColor(); - g.setColor(Color.WHITE); - g.drawOval(gradientPoint.x - 3, gradientPoint.y - 3, 6, 6); - g.setColor(saved); - } - }; - } - - private JPanel createTrackPanel(){ - return new JPanel() - { - public Dimension getPreferredSize() - { - return new Dimension(TRACK_WIDTH, IMG_HEIGHT); - } - - public void paint(Graphics g) - { - if (trackImage != null){ - g.drawImage(trackImage, 0, 0, this); - } - - } - }; - } - - /** - * This method uninstalls the DefaultHSBPanel. - * - * @param chooser The JColorChooser to remove this panel from. - */ - public void uninstallChooserPanel(JColorChooser chooser) - { - trackImage = null; - gradientImage = null; - gradientPanel = null; - slider = null; - - hSpinner = null; - sSpinner = null; - bSpinner = null; - - hRadio = null; - sRadio = null; - bRadio = null; - - removeAll(); - super.uninstallChooserPanel(chooser); - } - - /** - * This helper method creates the right side panel (the panel with the - * Spinners and TextFields). - * - * @return The right side panel. - */ - private Container buildRightPanel() - { - JPanel container = new JPanel(); - container.setLayout(new FlowLayout(FlowLayout.RIGHT)); - - // 主面板 - JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new BorderLayout(0, 10)); - UILabel label = new UILabel(); - label.setSize(200,200); - container.add(label); - container.add(mainPanel); - - // hsl和rgb面板 - JPanel hslAndRgbPanel = new JPanel(); - hslAndRgbPanel.setLayout(new BorderLayout(0,16)); - hslAndRgbPanel.add(initialHSLPanel(),BorderLayout.CENTER); - hslAndRgbPanel.add(initialRGBPanel(),BorderLayout.SOUTH); - - // 十六进制面板 - JPanel hexPanel = new JPanel(); - hexPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 8, 0)); - hexPanel.add(new UILabel("#")); - hexPanel.add(field); - - mainPanel.add(hslAndRgbPanel,BorderLayout.CENTER); - mainPanel.add(hexPanel,BorderLayout.SOUTH); - - return container; - } - - //初始化HSL部分 - private JPanel initialHSLPanel(){ - hRadio = new UIRadioButton("H"); - sRadio = new UIRadioButton("S"); - bRadio = new UIRadioButton("L"); - ButtonGroup group = new ButtonGroup(); - group.add(hRadio); - group.add(sRadio); - group.add(bRadio); - - hSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 359, 1)); - sSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 100, 1)); - bSpinner = new UIBasicSpinner(new SpinnerNumberModel(100, 0, 100, 1)); - hSpinner.setEnabled(true); - sSpinner.setEnabled(false); - bSpinner.setEnabled(false); - - MouseAdapter cl = new RadioStateListener(); - locked = HLOCKED; - hRadio.setSelected(true); - hRadio.addMouseListener(cl); - sRadio.addMouseListener(cl); - bRadio.addMouseListener(cl); - - ChangeListener scroll = new ImageScrollListener(); - hSpinner.addChangeListener(scroll); - sSpinner.addChangeListener(scroll); - bSpinner.addChangeListener(scroll); - - JPanel hslPanel = new JPanel(); - hslPanel.setLayout(new GridLayout(3,0,0,5)); - - JPanel hPanel = new JPanel(); - hPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); - hPanel.add(hRadio); - hPanel.add(hSpinner); - hslPanel.add(hPanel); - - JPanel sPanel = new JPanel(); - sPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); - sPanel.add(sRadio); - sPanel.add(sSpinner); - hslPanel.add(sPanel); - - JPanel lPanel = new JPanel(); - lPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); - lPanel.add(bRadio); - lPanel.add(bSpinner); - hslPanel.add(lPanel); - return hslPanel; - } - - private JPanel initialRGBPanel(){ - // 初始化RGB部分 - rSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 255, 1)); - gSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 255, 1)); - bbSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 255, 1)); - - rSpinner.setEnabled(true); - gSpinner.setEnabled(true); - bbSpinner.setEnabled(true); - - addRGBSpinnerChangeLisener(); - - TextDocumentListener listen = new TextDocumentListener(); - field = new UITextField(); - field.setPreferredSize(new Dimension(70,18)); - field.getDocument().addDocumentListener(listen); - - JPanel rgbPanel = new JPanel(); - rgbPanel.setLayout(new GridLayout(3,0,0,5)); - - JPanel rPanel = new JPanel(); - rPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); - rPanel.add(R); - rPanel.add(rSpinner); - rgbPanel.add(rPanel); - - JPanel gPanel = new JPanel(); - gPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); - gPanel.add(G); - gPanel.add(gSpinner); - rgbPanel.add(gPanel); - - JPanel bPanel = new JPanel(); - bPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); - bPanel.add(B); - bPanel.add(bbSpinner); - rgbPanel.add(bPanel); - - return rgbPanel; - } - - /** - * This method returns the small display icon. - * - * @return The small display icon. - */ - public Icon getSmallDisplayIcon() - { - return null; - } - - /** - * This method returns the large display icon. - * - * @return The large display icon. - */ - public Icon getLargeDisplayIcon() - { - return null; - } - - /** - * This method updates the gradient image with a new one taking the Hue - * value as the constant. - */ - private void updateHLockImage() - { - int index = 0; - int[] pix = new int[IMG_WIDTH * IMG_HEIGHT]; - float hValue = ((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE; - - for (int j = 0; j < IMG_HEIGHT; j++) - { - for (int i = 0; i < IMG_WIDTH; i++){ - pix[index++] = Color.HSBtoRGB(hValue, (IMG_WIDTH - i * 1f) / IMG_WIDTH, - (IMG_HEIGHT - j * 1f) / IMG_HEIGHT) | (BINARY_FOR_EIGHT << TWENTY_FOUR); + + gradientImage = createImage(new MemoryImageSource(IMG_WIDTH, IMG_HEIGHT, + pix, 0, IMG_WIDTH)); + } + + /** + * This method updates the gradient image with a new one taking the + * Saturation value as the constant. + */ + private void updateSLockImage() { + int[] pix = new int[IMG_WIDTH * IMG_HEIGHT]; + float sValue = ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE; + + int index = 0; + for (int j = 0; j < IMG_HEIGHT; j++) { + for (int i = 0; i < IMG_WIDTH; i++) { + pix[index++] = Color.HSBtoRGB(i * 1f / IMG_WIDTH, sValue, + (IMG_HEIGHT - j * 1f) / IMG_HEIGHT) | (BINARY_FOR_EIGHT << TWENTY_FOUR); + } } + + gradientImage = createImage(new MemoryImageSource(IMG_WIDTH, IMG_HEIGHT, + pix, 0, IMG_WIDTH)); } - gradientImage = createImage(new MemoryImageSource(IMG_WIDTH, IMG_HEIGHT, - pix, 0, IMG_WIDTH)); - } - - /** - * This method updates the gradient image with a new one taking the - * Brightness value as the constant. - */ - private void updateBLockImage() - { - int[] pix = new int[IMG_WIDTH * IMG_HEIGHT]; - float bValue = ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE; - - int index = 0; - for (int j = 0; j < IMG_HEIGHT; j++){ - for (int i = 0; i < IMG_WIDTH; i++){ - pix[index++] = Color.HSBtoRGB(i * 1f / IMG_WIDTH, - (IMG_HEIGHT - j * 1f) / IMG_HEIGHT, bValue) | (BINARY_FOR_EIGHT << TWENTY_FOUR); + /** + * This method calls the appropriate method to update the gradient image + * depending on which HSB value is constant. + */ + private void updateImage() { + switch (locked) { + case HLOCKED: + updateHLockImage(); + break; + case SLOCKED: + updateSLockImage(); + break; + case BLOCKED: + updateBLockImage(); + break; } } - gradientImage = createImage(new MemoryImageSource(IMG_WIDTH, IMG_HEIGHT, - pix, 0, IMG_WIDTH)); - } - - /** - * This method updates the gradient image with a new one taking the - * Saturation value as the constant. - */ - private void updateSLockImage() - { - int[] pix = new int[IMG_WIDTH * IMG_HEIGHT]; - float sValue = ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE; - - int index = 0; - for (int j = 0; j < IMG_HEIGHT; j++){ - for (int i = 0; i < IMG_WIDTH; i++){ - pix[index++] = Color.HSBtoRGB(i * 1f / IMG_WIDTH, sValue, - (IMG_HEIGHT - j * 1f) / IMG_HEIGHT)| (BINARY_FOR_EIGHT << TWENTY_FOUR); + /** + * This method updates the TextFields with the correct RGB values. + */ + private void updateTextFields() { + int c = getColorSelectionModel().getSelectedColor().getRGB(); + + removeRGBSpinnerChangeLisener(); + rSpinner.setValue(Integer.parseInt("" + (c >> BINARY_FOR_FOUR & HEX_FF))); + gSpinner.setValue(Integer.parseInt("" + (c >> BINARY_FOR_THTEE & HEX_FF))); + bbSpinner.setValue(Integer.parseInt("" + (c & HEX_FF))); + addRGBSpinnerChangeLisener(); + + repaint(); + } + + private void removeRGBSpinnerChangeLisener() { + rSpinner.removeChangeListener(rgbScroll); + gSpinner.removeChangeListener(rgbScroll); + bbSpinner.removeChangeListener(rgbScroll); + } + + private void addRGBSpinnerChangeLisener() { + rSpinner.addChangeListener(rgbScroll); + gSpinner.addChangeListener(rgbScroll); + bbSpinner.addChangeListener(rgbScroll); + } + + private void updateHexFields() { + Color color = getColorSelectionModel().getSelectedColor(); + + String R = Integer.toHexString(color.getRed()); + R = R.length() < 2 ? ('0' + R) : R; + String B = Integer.toHexString(color.getBlue()); + B = B.length() < 2 ? ('0' + B) : B; + String G = Integer.toHexString(color.getGreen()); + G = G.length() < 2 ? ('0' + G) : G; + + try { + field.setText(R + G + B); + } catch (Exception e) { + // 因为有了DocumentListener的监听,导致setText()的时候报错但不影响使用 + // 所以只捕捉,不处理 } + repaint(); } - - gradientImage = createImage(new MemoryImageSource(IMG_WIDTH, IMG_HEIGHT, - pix, 0, IMG_WIDTH)); - } - - /** - * This method calls the appropriate method to update the gradient image - * depending on which HSB value is constant. - */ - private void updateImage() - { - switch (locked) - { - case HLOCKED: - updateHLockImage(); - break; - case SLOCKED: - updateSLockImage(); - break; - case BLOCKED: - updateBLockImage(); - break; - } - } - - /** - * This method updates the TextFields with the correct RGB values. - */ - private void updateTextFields() - { - int c = getColorSelectionModel().getSelectedColor().getRGB(); - - removeRGBSpinnerChangeLisener(); - rSpinner.setValue(Integer.parseInt("" + (c >> BINARY_FOR_FOUR & HEX_FF))); - gSpinner.setValue(Integer.parseInt("" + (c >> BINARY_FOR_THTEE & HEX_FF))); - bbSpinner.setValue(Integer.parseInt("" + (c & HEX_FF))); - addRGBSpinnerChangeLisener(); - - repaint(); - } - - private void removeRGBSpinnerChangeLisener(){ - rSpinner.removeChangeListener(rgbScroll); - gSpinner.removeChangeListener(rgbScroll); - bbSpinner.removeChangeListener(rgbScroll); - } - - private void addRGBSpinnerChangeLisener(){ - rSpinner.addChangeListener(rgbScroll); - gSpinner.addChangeListener(rgbScroll); - bbSpinner.addChangeListener(rgbScroll); - } - - private void updateHexFields() - { - Color color = getColorSelectionModel().getSelectedColor(); - - String R = Integer.toHexString(color.getRed()); - R = R.length() < 2 ? ('0' + R) : R; - String B = Integer.toHexString(color.getBlue()); - B = B.length() < 2 ? ('0' + B) : B; - String G = Integer.toHexString(color.getGreen()); - G = G.length() < 2 ? ('0' + G) : G; - - try{ - field.setText(R + G + B); - }catch(Exception e){ - // 因为有了DocumentListener的监听,导致setText()的时候报错但不影响使用 - // 所以只捕捉,不处理 + + /** + * This method updates the slider in response to making a different HSB + * property the constant. + */ + private void updateSlider() { + if (slider == null) { + return; + } + + slider.setMinimum(0); + if (locked == HLOCKED) { + internalChange = true; + slider.setValue(((Number) hSpinner.getValue()).intValue()); + slider.setMaximum(359); + internalChange = false; + slider.setInverted(true); + } else { + slider.setInverted(false); + if (locked == SLOCKED) { + slider.setValue(((Number) sSpinner.getValue()).intValue()); + } else { + slider.setValue(((Number) bSpinner.getValue()).intValue()); + } + slider.setMaximum(100); + slider.setInverted(false); + } + repaint(); } - repaint(); - } - - /** - * This method updates the slider in response to making a different HSB - * property the constant. - */ - private void updateSlider() - { - if (slider == null){ - return; + + /** + * This method updates the track gradient image depending on which HSB + * property is constant. + */ + private void updateTrack() { + switch (locked) { + case HLOCKED: + updateHTrack(); + break; + case SLOCKED: + updateSTrack(); + break; + case BLOCKED: + updateBTrack(); + break; + } } - - slider.setMinimum(0); - if (locked == HLOCKED) - { - internalChange = true; - slider.setValue(((Number) hSpinner.getValue()).intValue()); - slider.setMaximum(359); - internalChange = false; - slider.setInverted(true); - } - else - { - slider.setInverted(false); - if (locked == SLOCKED){ - slider.setValue(((Number) sSpinner.getValue()).intValue()); - }else{ - slider.setValue(((Number) bSpinner.getValue()).intValue()); - } - slider.setMaximum(100); - slider.setInverted(false); - } - repaint(); - } - - /** - * This method updates the track gradient image depending on which HSB - * property is constant. - */ - private void updateTrack() - { - switch (locked) - { - case HLOCKED: - updateHTrack(); - break; - case SLOCKED: - updateSTrack(); - break; - case BLOCKED: - updateBTrack(); - break; - } - } - - /** - * This method updates the track gradient image if the Hue value is allowed - * to change (according to the UIRadioButtons). - */ - private void updateHTrack() - { - int trackIndex = 0; - int[] trackPix = new int[TRACK_WIDTH * IMG_HEIGHT]; - - for (int j = 0; j < IMG_HEIGHT; j++){ - for (int i = 0; i < TRACK_WIDTH; i++){ - trackPix[trackIndex++] = Color.HSBtoRGB(j * 1f / IMG_HEIGHT, 1f, 1f) - | (BINARY_FOR_EIGHT << TWENTY_FOUR); + + /** + * This method updates the track gradient image if the Hue value is allowed + * to change (according to the UIRadioButtons). + */ + private void updateHTrack() { + int trackIndex = 0; + int[] trackPix = new int[TRACK_WIDTH * IMG_HEIGHT]; + + for (int j = 0; j < IMG_HEIGHT; j++) { + for (int i = 0; i < TRACK_WIDTH; i++) { + trackPix[trackIndex++] = Color.HSBtoRGB(j * 1f / IMG_HEIGHT, 1f, 1f) + | (BINARY_FOR_EIGHT << TWENTY_FOUR); + } } + + trackImage = createImage(new MemoryImageSource(TRACK_WIDTH, IMG_HEIGHT, + trackPix, 0, TRACK_WIDTH)); } - trackImage = createImage(new MemoryImageSource(TRACK_WIDTH, IMG_HEIGHT, - trackPix, 0, TRACK_WIDTH)); - } - - /** - * This method updates the track gradient image if the Saturation value is - * allowed to change (according to the UIRadioButtons). - */ - private void updateSTrack() - { - int[] trackPix = new int[TRACK_WIDTH * IMG_HEIGHT]; - - float hValue = ((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE; - float bValue = ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE; - - int trackIndex = 0; - for (int j = 0; j < IMG_HEIGHT; j++){ - for (int i = 0; i < TRACK_WIDTH; i++){ - trackPix[trackIndex++] = Color.HSBtoRGB(hValue, - (IMG_HEIGHT - j * 1f) / IMG_HEIGHT, - bValue) | (BINARY_FOR_EIGHT << TWENTY_FOUR); + /** + * This method updates the track gradient image if the Saturation value is + * allowed to change (according to the UIRadioButtons). + */ + private void updateSTrack() { + int[] trackPix = new int[TRACK_WIDTH * IMG_HEIGHT]; + + float hValue = ((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE; + float bValue = ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE; + + int trackIndex = 0; + for (int j = 0; j < IMG_HEIGHT; j++) { + for (int i = 0; i < TRACK_WIDTH; i++) { + trackPix[trackIndex++] = Color.HSBtoRGB(hValue, + (IMG_HEIGHT - j * 1f) / IMG_HEIGHT, + bValue) | (BINARY_FOR_EIGHT << TWENTY_FOUR); + } } + + trackImage = createImage(new MemoryImageSource(TRACK_WIDTH, IMG_HEIGHT, + trackPix, 0, TRACK_WIDTH)); } - trackImage = createImage(new MemoryImageSource(TRACK_WIDTH, IMG_HEIGHT, - trackPix, 0, TRACK_WIDTH)); - } - - /** - * This method updates the track gradient image if the Brightness value is - * allowed to change (according to the UIRadioButtons). - */ - private void updateBTrack() - { - int[] trackPix = new int[TRACK_WIDTH * IMG_HEIGHT]; - - float hValue = ((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE; - float sValue = ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE; - - int trackIndex = 0; - for (int j = 0; j < IMG_HEIGHT; j++){ - for (int i = 0; i < TRACK_WIDTH; i++){ - trackPix[trackIndex++] = Color.HSBtoRGB(hValue, sValue, - (IMG_HEIGHT - j * 1f) / IMG_HEIGHT) | (BINARY_FOR_EIGHT << TWENTY_FOUR); + /** + * This method updates the track gradient image if the Brightness value is + * allowed to change (according to the UIRadioButtons). + */ + private void updateBTrack() { + int[] trackPix = new int[TRACK_WIDTH * IMG_HEIGHT]; + + float hValue = ((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE; + float sValue = ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE; + + int trackIndex = 0; + for (int j = 0; j < IMG_HEIGHT; j++) { + for (int i = 0; i < TRACK_WIDTH; i++) { + trackPix[trackIndex++] = Color.HSBtoRGB(hValue, sValue, + (IMG_HEIGHT - j * 1f) / IMG_HEIGHT) | (BINARY_FOR_EIGHT << TWENTY_FOUR); + } } + + trackImage = createImage(new MemoryImageSource(TRACK_WIDTH, IMG_HEIGHT, + trackPix, 0, TRACK_WIDTH)); + } + + public Color getColor() { + return getColorSelectionModel().getSelectedColor(); } - trackImage = createImage(new MemoryImageSource(TRACK_WIDTH, IMG_HEIGHT, - trackPix, 0, TRACK_WIDTH)); - } + public void setColor(Color color) { + getColorSelectionModel().setSelectedColor(color); + } + + public void colorSetted(ColorCell cc) { + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/style/color/NewColorSelectPane.java b/designer_base/src/com/fr/design/style/color/NewColorSelectPane.java index bbecf01d3..ba28b4201 100644 --- a/designer_base/src/com/fr/design/style/color/NewColorSelectPane.java +++ b/designer_base/src/com/fr/design/style/color/NewColorSelectPane.java @@ -78,10 +78,21 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { // center JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); this.add(centerPane, BorderLayout.CENTER); - + + // 第一行,1个取色按钮 + 7个最近使用的颜色 + JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout()); + row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0)); + row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7 + centerPane.add(row1Pane); + + // 取色按钮 + UIButton pickColorButton = PickColorButtonFactory.getPickColorButton(this, PickColorButtonFactory.IconType.ICON16); + row1Pane.add(pickColorButton, BorderLayout.WEST); + // 最近使用 - usedColorPane = new UsedColorPane(1, 8, ColorSelectConfigManager.getInstance().getColors(),this); - centerPane.add(usedColorPane.getPane()); + usedColorPane = new UsedColorPane(1, 7, ColorSelectConfigManager.getInstance().getColors(),this); + usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 8)); + row1Pane.add(usedColorPane.getPane()); JPanel menuColorPane1 = new JPanel(); centerPane.add(menuColorPane1); @@ -204,4 +215,6 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { usedColorPane.updateUsedColor(); } + + } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/style/color/PickColorButtonFactory.java b/designer_base/src/com/fr/design/style/color/PickColorButtonFactory.java new file mode 100644 index 000000000..0ffd293c8 --- /dev/null +++ b/designer_base/src/com/fr/design/style/color/PickColorButtonFactory.java @@ -0,0 +1,46 @@ +package com.fr.design.style.color; + +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; + +/** + * Created by plough on 2016/12/22. + */ +public class PickColorButtonFactory { + + public static UIButton getPickColorButton(ColorSelectable colorSelectable, IconType iconType) { + return getPickColorButton(colorSelectable, iconType, false); + } + + public static UIButton getPickColorButton(final ColorSelectable colorSelectable, IconType iconType, final Boolean setColorRealTime) { + UIButton pickColorButton = new UIButton(); + + if (iconType == IconType.ICON16) { + pickColorButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/gui/colorPicker/colorPicker16.png")); + pickColorButton.setPreferredSize(new Dimension(16, 16)); + } else { + pickColorButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/gui/colorPicker/colorPicker18.png")); + pickColorButton.setPreferredSize(new Dimension(18, 18)); + } + pickColorButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + pickColorButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ColorPicker colorPicker = new ColorPicker(colorSelectable, setColorRealTime); + colorPicker.start(); + } + }); + + return pickColorButton; + } + + // 取色器按钮使用的图标 + public enum IconType { + ICON16, ICON18 + } +} diff --git a/designer_base/src/com/fr/env/RemoteEnv.java b/designer_base/src/com/fr/env/RemoteEnv.java index 70c18fbd0..a0bdc0e13 100644 --- a/designer_base/src/com/fr/env/RemoteEnv.java +++ b/designer_base/src/com/fr/env/RemoteEnv.java @@ -513,8 +513,10 @@ public class RemoteEnv implements Env { } private void stopLogTimer() { - logTimer.cancel(); - logTimer = null; + if(logTimer != null) { + logTimer.cancel(); + logTimer = null; + } } /** @@ -2063,6 +2065,17 @@ public class RemoteEnv implements Env { } + + /** + * 获取插件的配置目录 + * + * @param plugin + */ + public String getPluginFilePath(Plugin plugin) { + + return StringUtils.EMPTY; + } + public void readPluginLicenses() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); HashMap para = new HashMap(); diff --git a/designer_chart/build.performance.gradle b/designer_chart/build.performance.gradle new file mode 100644 index 000000000..c8f7e2ac3 --- /dev/null +++ b/designer_chart/build.performance.gradle @@ -0,0 +1,69 @@ + +apply plugin: 'java' +tasks.withType(JavaCompile){ + options.encoding = 'UTF-8' +} +//指定构建的jdk版本 +sourceCompatibility=1.7 +//指定生成jar包版本 +version='8.0' +//生成jar包重命名 +jar{ + baseName='fr-designer-chart' +} + + +def srcDir="." +def baseDir=".." + +//指定源码路径 +sourceSets{ + main{ + java{ + srcDirs=["${srcDir}/src"] + } + } +} +//获取什么分支名 +FileTree files =fileTree(dir:'./',include:'build.*.gradle') +def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\')) +buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\')) +def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1) + +//声明外部依赖 +dependencies{ + compile fileTree(dir:"../${baseDir}/lib",include:'**/*.jar') + compile fileTree(dir:"../${baseDir}",include:"**/build/libs/*.jar",exclude:"bi/**/*.jar") + testCompile 'junit:junit:4.12' +} +//复制非.java文件到classes文件夹下参与打包 +task copyFile(type:Copy,dependsOn:compileJava){ + copy{ + from ("${srcDir}/src"){ + exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html' + } + into 'build/classes/main' + } + +} + + +//压缩项目中的js文件 +task compressJS{ + ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ + classpath { + fileset(dir:"../${baseDir}/lib4build",includes:'**/*.jar') + } + } + ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){ + fileset (dir:"${srcDir}/src"){ + include (name:'**/*.js') + include (name:'**/*.css') + } + + } +} +jar.dependsOn compressJS + + + diff --git a/designer_chart/build.performance.gradle.bak b/designer_chart/build.performance.gradle.bak new file mode 100644 index 000000000..7a57794c4 --- /dev/null +++ b/designer_chart/build.performance.gradle.bak @@ -0,0 +1,69 @@ + +apply plugin: 'java' +tasks.withType(JavaCompile){ + options.encoding = 'UTF-8' +} +//指定构建的jdk版本 +sourceCompatibility=1.7 +//指定生成jar包版本 +version='8.0' +//生成jar包重命名 +jar{ + baseName='fr-designer-chart' +} + + +def srcDir="." +def baseDir=".." + +//指定源码路径 +sourceSets{ + main{ + java{ + srcDirs=["${srcDir}/src"] + } + } +} +//获取什么分支名 +FileTree files =fileTree(dir:'./',include:'build.*.gradle') +def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\')) +buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\')) +def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1) + +//声明外部依赖 +dependencies{ + compile fileTree(dir:"../${baseDir}/lib",include:'**/*.jar') + compile fileTree(dir:"../${baseDir}",include:"**/build/libs/*.jar",exclude:"bi/**/*.jar") + testCompile 'junit:junit:4.12' +} +//复制非.java文件到classes文件夹下参与打包 +task copyFile(type:Copy,dependsOn:compileJava){ + copy{ + from ("${srcDir}/src"){ + exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html' + } + into 'build/classes/main' + } + +} + + +//压缩项目中的js文件 +task compressJS{ + ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ + classpath { + fileset(dir:'../${baseDir}/lib4build',includes:'**/*.jar') + } + } + ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){ + fileset (dir:"${srcDir}/src"){ + include (name:'**/*.js') + include (name:'**/*.css') + } + + } +} +jar.dependsOn compressJS + + + diff --git a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java index 3bf990880..12cbef841 100644 --- a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java @@ -25,6 +25,7 @@ import com.fr.general.*; import com.fr.plugin.PluginCollector; import com.fr.plugin.PluginLicenseManager; import com.fr.plugin.PluginMessage; +import com.fr.stable.ArrayUtils; import com.fr.stable.EnvChangedListener; import com.fr.stable.StringUtils; import com.fr.stable.fun.Authorize; @@ -85,7 +86,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh for (int i = 0; i < typeName.length; i++) { String plotID = typeName[i].getPlotID(); Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); - if(rowChart == null) { + if(ArrayUtils.isEmpty(rowChart)) { continue; } String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); diff --git a/designer_chart/src/com/fr/design/module/ChartDesignerModule.java b/designer_chart/src/com/fr/design/module/ChartDesignerModule.java index 38034efd0..979be5c92 100644 --- a/designer_chart/src/com/fr/design/module/ChartDesignerModule.java +++ b/designer_chart/src/com/fr/design/module/ChartDesignerModule.java @@ -1 +1 @@ -package com.fr.design.module; import com.fr.chart.base.ChartInternationalNameContentBean; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.actions.core.ActionFactory; import com.fr.design.chart.ChartDialog; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.gui.core.WidgetOption; import com.fr.design.mainframe.App; import com.fr.design.mainframe.ChartPropertyPane; import com.fr.form.ui.ChartEditor; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import javax.swing.*; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 13-7-8 * Time: 上午9:13 */ public class ChartDesignerModule extends DesignModule { public void start() { super.start(); dealBeforeRegister(); register(); registerFloatEditor(); } protected void dealBeforeRegister(){ StableFactory.registerMarkedClass(ExtraChartDesignClassManagerProvider.XML_TAG, ChartTypeInterfaceManager.class); StableFactory.getStaticMarkedInstanceObjectFromClass(ExtraChartDesignClassManagerProvider.XML_TAG, ExtraChartDesignClassManagerProvider.class); } private void register(){ DesignModuleFactory.registerHyperlinkGroupType(new ChartHyperlinkGroup()); DesignModuleFactory.registerChartEditorClass(ChartEditor.class); DesignModuleFactory.registerChartComponentClass(ChartComponent.class); DesignModuleFactory.registerChartDialogClass(ChartDialog.class); DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction()); } protected void registerFloatEditor() { ActionFactory.registerChartCollection(ChartCollection.class); } /** * 返回设计器能打开的模板类型的一个数组列表 * * @return 可以打开的模板类型的数组 */ public App[] apps4TemplateOpener() { return new App[0]; } protected WidgetOption[] options4Show() { ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; for (int i = 0; i < typeName.length; i++) { String plotID = typeName[i].getPlotID(); Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); if(rowChart == null) { continue; } String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); Icon icon = IOUtils.readIcon(iconPath); child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); } return child; } public String getInterNationalName() { return Inter.getLocText("FR-Chart-Design_ChartModule"); } } \ No newline at end of file +package com.fr.design.module; import com.fr.chart.base.ChartInternationalNameContentBean; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.actions.core.ActionFactory; import com.fr.design.chart.ChartDialog; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.gui.core.WidgetOption; import com.fr.design.mainframe.App; import com.fr.design.mainframe.ChartPropertyPane; import com.fr.form.ui.ChartEditor; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import javax.swing.*; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 13-7-8 * Time: 上午9:13 */ public class ChartDesignerModule extends DesignModule { public void start() { super.start(); dealBeforeRegister(); register(); registerFloatEditor(); } protected void dealBeforeRegister(){ StableFactory.registerMarkedClass(ExtraChartDesignClassManagerProvider.XML_TAG, ChartTypeInterfaceManager.class); StableFactory.getStaticMarkedInstanceObjectFromClass(ExtraChartDesignClassManagerProvider.XML_TAG, ExtraChartDesignClassManagerProvider.class); } private void register(){ DesignModuleFactory.registerHyperlinkGroupType(new ChartHyperlinkGroup()); DesignModuleFactory.registerChartEditorClass(ChartEditor.class); DesignModuleFactory.registerChartComponentClass(ChartComponent.class); DesignModuleFactory.registerChartDialogClass(ChartDialog.class); DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction()); } protected void registerFloatEditor() { ActionFactory.registerChartCollection(ChartCollection.class); } /** * 返回设计器能打开的模板类型的一个数组列表 * * @return 可以打开的模板类型的数组 */ public App[] apps4TemplateOpener() { return new App[0]; } protected WidgetOption[] options4Show() { ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; for (int i = 0; i < typeName.length; i++) { String plotID = typeName[i].getPlotID(); Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); if (ArrayUtils.isEmpty(rowChart)) { continue; } String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); Icon icon = IOUtils.readIcon(iconPath); child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); } return child; } public String getInterNationalName() { return Inter.getLocText("FR-Chart-Design_ChartModule"); } } \ No newline at end of file diff --git a/designer_form/build.dev.gradle b/designer_form/build.dev.gradle index 2b727caac..20dc49a33 100644 --- a/designer_form/build.dev.gradle +++ b/designer_form/build.dev.gradle @@ -20,7 +20,7 @@ sourceSets{ main{ java{ srcDirs=["${srcDir}/src", -"${srcDir}/../designer/src"] + "${srcDir}/../designer/src"] } } } diff --git a/designer_form/build.dev.gradle.bak b/designer_form/build.dev.gradle.bak index 24ee9430a..2b727caac 100644 --- a/designer_form/build.dev.gradle.bak +++ b/designer_form/build.dev.gradle.bak @@ -34,7 +34,7 @@ def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1) //显示依赖jar包 FileTree f=fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar") f.each{File file-> - println "----${f.path}" + println "----${file.path}" } //声明外部依赖 diff --git a/designer_form/build.performance.gradle b/designer_form/build.performance.gradle new file mode 100644 index 000000000..5c14f78a4 --- /dev/null +++ b/designer_form/build.performance.gradle @@ -0,0 +1,70 @@ + +apply plugin: 'java' +tasks.withType(JavaCompile){ + options.encoding = 'UTF-8' +} +//指定构建的jdk版本 +sourceCompatibility=1.7 +//指定生成jar包版本 +version='8.0' +//生成jar包重命名 +jar{ + baseName='fr-designer-report' +} + + +def srcDir="." +def baseDir=".." + +//指定源码路径 +sourceSets{ + main{ + java{ + srcDirs=["${srcDir}/src", + "${srcDir}/../designer/src"] + } + } +} +//获取什么分支名 +FileTree files =fileTree(dir:'./',include:'build.*.gradle') +def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\')) +buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\')) +def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1) + +//声明外部依赖 +dependencies{ + compile fileTree(dir:"../${baseDir}/lib",include:'**/*.jar') + compile fileTree(dir:"../${baseDir}",include:"**/build/libs/*.jar",exclude:"bi/**/*.jar") + testCompile 'junit:junit:4.12' +} +//复制非.java文件到classes文件夹下参与打包 +task copyFile(type:Copy,dependsOn:compileJava){ + copy{ + from ("${srcDir}/src"){ + exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html' + } + into 'build/classes/main' + } + +} + + +//压缩项目中的js文件 +task compressJS{ + ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ + classpath { + fileset(dir:"../${baseDir}/lib4build",includes:'**/*.jar') + } + } + ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){ + fileset (dir:"${srcDir}/src"){ + include (name:'**/*.js') + include (name:'**/*.css') + } + + } +} +jar.dependsOn compressJS + + + diff --git a/designer_form/build.performance.gradle.bak b/designer_form/build.performance.gradle.bak new file mode 100644 index 000000000..8d1c70877 --- /dev/null +++ b/designer_form/build.performance.gradle.bak @@ -0,0 +1,69 @@ + +apply plugin: 'java' +tasks.withType(JavaCompile){ + options.encoding = 'UTF-8' +} +//指定构建的jdk版本 +sourceCompatibility=1.7 +//指定生成jar包版本 +version='8.0' +//生成jar包重命名 +jar{ + baseName='fr-designer-report' +} + + +def srcDir="." +def baseDir=".." + +//指定源码路径 +sourceSets{ + main{ + java{ + srcDirs=["${srcDir}/src"] + } + } +} +//获取什么分支名 +FileTree files =fileTree(dir:'./',include:'build.*.gradle') +def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\')) +buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\')) +def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1) + +//声明外部依赖 +dependencies{ + compile fileTree(dir:"../${baseDir}/lib",include:'**/*.jar') + compile fileTree(dir:"../${baseDir}",include:"**/build/libs/*.jar",exclude:"bi/**/*.jar") + testCompile 'junit:junit:4.12' +} +//复制非.java文件到classes文件夹下参与打包 +task copyFile(type:Copy,dependsOn:compileJava){ + copy{ + from ("${srcDir}/src"){ + exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html' + } + into 'build/classes/main' + } + +} + + +//压缩项目中的js文件 +task compressJS{ + ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ + classpath { + fileset(dir:"../${baseDir}/lib4build",includes:'**/*.jar') + } + } + ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){ + fileset (dir:"${srcDir}/src"){ + include (name:'**/*.js') + include (name:'**/*.css') + } + + } +} +jar.dependsOn compressJS + + + diff --git a/designer_form/src/com/fr/design/designer/creator/XCreator.java b/designer_form/src/com/fr/design/designer/creator/XCreator.java index f80f20b58..ba2a56ce0 100644 --- a/designer_form/src/com/fr/design/designer/creator/XCreator.java +++ b/designer_form/src/com/fr/design/designer/creator/XCreator.java @@ -426,7 +426,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo */ public boolean acceptType(Class... acceptTypes) { for (Class type : acceptTypes) { - if (StableUtils.classInstanceOf(this.getClass(), type)) { + if (StableUtils.objectInstanceOf(this, type)) { return true; } } diff --git a/designer_form/src/com/fr/design/mainframe/actions/EmbeddedFormExportExportAction.java b/designer_form/src/com/fr/design/mainframe/actions/EmbeddedFormExportExportAction.java index 4d4a3b7e4..20c44f65d 100644 --- a/designer_form/src/com/fr/design/mainframe/actions/EmbeddedFormExportExportAction.java +++ b/designer_form/src/com/fr/design/mainframe/actions/EmbeddedFormExportExportAction.java @@ -87,10 +87,10 @@ public class EmbeddedFormExportExportAction extends JTemplateAction{ FRLogger.getLogger().error("Error In Make New File"); } fileChooserPane = null; - FRContext.getLogger().info("\"" + file.getName() + "\"" + Inter.getLocText("Prepare_Export") + "!"); + FRContext.getLogger().info("\"" + file.getName() + "\"" + Inter.getLocText("FR-Designer_Prepare_Export") + "!"); (progressbar = new FRProgressBar(createExportWork(file, tpl, parameterMap), designerFrame, - Inter.getLocText("Exporting"), "", 0, 100)).start(); + Inter.getLocText("FR-Designer_Exporting"), "", 0, 100)).start(); } private boolean isOk(int saveValue){ @@ -136,13 +136,13 @@ public class EmbeddedFormExportExportAction extends JTemplateAction{ fileOutputStream.close(); this.setProgress(100); - FRContext.getLogger().info("\"" + fileGetName + "\"" + Inter.getLocText("Finish_Export") + "!"); + FRContext.getLogger().info("\"" + fileGetName + "\"" + Inter.getLocText("FR-Designer_Finish_Export") + "!"); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Inter.getLocText("Exported_successfully") + "\n" + filePath); + Inter.getLocText("FR-Designer_Exported_successfully") + "\n" + filePath); } catch (Exception exp) { this.setProgress(100); FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Export_failed") + "\n" + filePath); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Export_failed") + "\n" + filePath); } return null; }