From 9024ca56b8568fcabc92d54d681c7f26295a39c2 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Tue, 25 Jul 2017 11:07:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/ElementCasePane.java | 2 +- .../mainframe/ReportComponentComposite.java | 54 ++-- designer/src/com/fr/poly/PolyDesigner.java | 265 +++++++++--------- .../fr/design/mainframe/JFormSliderPane.java | 158 +++++------ .../com/fr/design/mainframe/JSliderPane.java | 176 ++++++------ 5 files changed, 322 insertions(+), 333 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/ElementCasePane.java b/designer/src/com/fr/design/mainframe/ElementCasePane.java index 7683d8c3b..a04de9538 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePane.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePane.java @@ -297,7 +297,7 @@ public abstract class ElementCasePane extends Tar if(DesignerContext.getReferencedElementCasePane() == null){ return; } - + ((ElementCasePane) DesignerContext.getReferencedElementCasePane()).getGrid().setNotShowingTableSelectPane(true); ((ElementCasePane) DesignerContext.getReferencedElementCasePane()).getGrid().setCursor(UIConstants.CELL_DEFAULT_CURSOR); DesignerContext.setReferencedElementCasePane(null); diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index f2e81e00a..c54fd51b2 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -1,17 +1,5 @@ package com.fr.design.mainframe; -import java.awt.BorderLayout; -import java.awt.event.*; -import java.util.ArrayList; - -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JSplitPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - import com.fr.base.FRContext; import com.fr.base.ScreenResolution; import com.fr.design.designer.EditingState; @@ -23,9 +11,15 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.Inter; import com.fr.grid.Grid; import com.fr.main.impl.WorkBook; -import com.fr.poly.PolyArea; import com.fr.report.report.TemplateReport; +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.*; +import java.util.ArrayList; + /** * 整个报表编辑区域 包括滚动条、中间的grid或者聚合块、下面的sheetTab * @@ -56,7 +50,6 @@ public class ReportComponentComposite extends JComponent { /** * Constructor with workbook.. - * */ public ReportComponentComposite(JWorkBook jwb) { setFocusable(true); @@ -80,22 +73,24 @@ public class ReportComponentComposite extends JComponent { public void keyTyped(KeyEvent e) { } + @Override public void keyPressed(KeyEvent e) { - if( e.isControlDown()){ - isCtrl = true ; + if (e.isControlDown()) { + isCtrl = true; } } + @Override public void keyReleased(KeyEvent e) { - isCtrl = false ; + isCtrl = false; } }; MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { - if (isCtrl){ + if (isCtrl) { int dir = e.getWheelRotation(); int old_resolution = (int) jSliderContainer.getShowVal().getValue(); jSliderContainer.getShowVal().setValue(old_resolution - (dir * MIN)); @@ -106,10 +101,10 @@ public class ReportComponentComposite extends JComponent { ChangeListener showValSpinnerChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - double value = (int) ((UIBasicSpinner)e.getSource()).getValue(); + double value = (int) ((UIBasicSpinner) e.getSource()).getValue(); value = value > MAX ? MAX : value; value = value < MIN ? MIN : value; - int resolution = (int) (ScreenResolution.getScreenResolution()*value/HUND); + int resolution = (int) (ScreenResolution.getScreenResolution() * value / HUND); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution); } }; @@ -117,9 +112,9 @@ public class ReportComponentComposite extends JComponent { ItemListener selfAdaptButtonItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - if (jSliderContainer.getSelfAdaptButton().isSelected()){ + if (jSliderContainer.getSelfAdaptButton().isSelected()) { int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().selfAdaptUpdate(); - jSliderContainer.getShowVal().setValue(resolution*HUND/ScreenResolution.getScreenResolution()); + jSliderContainer.getShowVal().setValue(resolution * HUND / ScreenResolution.getScreenResolution()); } } }; @@ -166,11 +161,10 @@ public class ReportComponentComposite extends JComponent { } /** - * 移除选中状态 - * - * @date 2015-2-5-上午11:41:44 - * - */ + * 移除选中状态 + * + * @date 2015-2-5-上午11:41:44 + */ public void removeSelection() { if (centerCardPane.editingComponet instanceof WorkSheetDesigner) { ((WorkSheetDesigner) centerCardPane.editingComponet).removeSelection(); @@ -188,7 +182,7 @@ public class ReportComponentComposite extends JComponent { return sheetNameTab.getSelectedIndex(); } - public JSliderPane getjSliderContainer(){ + public JSliderPane getjSliderContainer() { return this.jSliderContainer; } @@ -240,8 +234,8 @@ public class ReportComponentComposite extends JComponent { splitpane.setBorder(null); splitpane.setDividerSize(3); splitpane.setResizeWeight(1); - southPane.add(hbarContainer,BorderLayout.NORTH); - southPane.add(splitpane,BorderLayout.CENTER); + southPane.add(hbarContainer, BorderLayout.NORTH); + southPane.add(splitpane, BorderLayout.CENTER); return southPane; } diff --git a/designer/src/com/fr/poly/PolyDesigner.java b/designer/src/com/fr/poly/PolyDesigner.java index 57413a129..088ef95e0 100644 --- a/designer/src/com/fr/poly/PolyDesigner.java +++ b/designer/src/com/fr/poly/PolyDesigner.java @@ -3,20 +3,6 @@ */ package com.fr.poly; -import java.awt.*; -import java.awt.event.*; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.AbstractAction; -import javax.swing.ActionMap; -import javax.swing.InputMap; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JScrollBar; -import javax.swing.KeyStroke; - import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.base.GraphHelper; @@ -47,11 +33,7 @@ import com.fr.design.utils.gui.LayoutUtils; import com.fr.general.ComparatorUtils; import com.fr.grid.selection.Selection; import com.fr.poly.actions.DeleteBlockAction; -import com.fr.poly.creator.BlockCreator; -import com.fr.poly.creator.BlockEditor; -import com.fr.poly.creator.ECBlockCreator; -import com.fr.poly.creator.ECBlockEditor; -import com.fr.poly.creator.PolyElementCasePane; +import com.fr.poly.creator.*; import com.fr.poly.hanlder.DataEditingListener; import com.fr.poly.hanlder.PolyDesignerDropTarget; import com.fr.poly.model.AddedData; @@ -61,13 +43,21 @@ import com.fr.report.block.Block; import com.fr.report.poly.PolyWorkSheet; import com.fr.report.poly.TemplateBlock; import com.fr.stable.ArrayUtils; -import com.fr.stable.CoreGraphHelper; import com.fr.stable.StringUtils; import com.fr.stable.unit.FU; import com.fr.stable.unit.OLDPIX; import com.fr.stable.unit.UNIT; import com.fr.stable.unit.UnitRectangle; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.List; + /** * @author richer * @since 6.5.3 聚合报表的设计块,不包括底部和右边的滚动条以及左边和上边的像素标识条 @@ -85,6 +75,7 @@ public class PolyDesigner extends ReportComponent jt = DesignerContext.getDesignerFrame().getSelectedJTemplate(); - if(jt != null){ - jt.setComposite(); - } + if (jt != null) { + jt.setComposite(); + } DesignerContext.getDesignerFrame().resetToolkitByPlus(DesignerContext.getDesignerFrame().getSelectedJTemplate()); if (BaseUtils.isAuthorityEditing()) { EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); @@ -918,8 +921,9 @@ public class PolyDesigner extends ReportComponent FOUR_HUNDRED){ + resolutionTimes = divide(showValue, 100, 2); + if (val > FOUR_HUNDRED) { showValSpinner.setValue(FOUR_HUNDRED); val = FOUR_HUNDRED; } - if (val < TEN){ + if (val < TEN) { showValSpinner.setValue(TEN); val = TEN; } @@ -197,11 +199,10 @@ public class JFormSliderPane extends JPanel { //定义一个监听器,用于监听所有滑动条 - ChangeListener listener = new ChangeListener() - { - public void stateChanged( ChangeEvent event) { + ChangeListener listener = new ChangeListener() { + public void stateChanged(ChangeEvent event) { //取出滑动条的值,并在文本中显示出来 - if (!isButtonOrIsTxt){ + if (!isButtonOrIsTxt) { customButton.setSelected(true); EventQueue.invokeLater(new Runnable() { public void run() { @@ -211,50 +212,50 @@ public class JFormSliderPane extends JPanel { showValSpinner.setValue(times); } }); - }else { + } else { isButtonOrIsTxt = false; } } }; - ItemListener radioButtonItemListener = new ItemListener() { + ItemListener radioButtonItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - JRadioButton temp=(JRadioButton)e.getSource(); - if(temp.isSelected()){ + JRadioButton temp = (JRadioButton) e.getSource(); + if (temp.isSelected()) { showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%")))); } } }; - private void refreshSlider(int val){ + private void refreshSlider(int val) { showValue = val; - if (showValue >HUNDRED){ - slider.setValue((int)(showValue+TWO_HUNDRED)/SIX); - }else if (showValue HUNDRED) { + slider.setValue((int) (showValue + TWO_HUNDRED) / SIX); + } else if (showValue < HUNDRED) { + slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT)); + } else if (showValue == HUNDRED) { slider.setValue(HALF_HUNDRED); } } - private void refreshBottun(int val){ - showValButton.setText(val+"%"); + private void refreshBottun(int val) { + showValButton.setText(val + "%"); } - public double getResolutionTimes(){ + public double getResolutionTimes() { return this.resolutionTimes; } - public int getshowValue(){ + public int getshowValue() { return this.showValue; } - public static double divide(double v1, double v2,int scale) { + public static double divide(double v1, double v2, int scale) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); - return b1.divide(b2,scale).doubleValue(); + return b1.divide(b2, scale).doubleValue(); } ActionListener buttonActionListener = new ActionListener() { @@ -262,22 +263,22 @@ public class JFormSliderPane extends JPanel { public void actionPerformed(ActionEvent e) { showValue = (int) showValSpinner.getValue(); isButtonOrIsTxt = true; - if(e.getActionCommand().equals("less")){ + if (e.getActionCommand().equals("less")) { int newDownVal = showValue - TEN; - if (newDownVal >= TEN ){ + if (newDownVal >= TEN) { showValue = newDownVal; showValSpinner.setValue(newDownVal); - }else { + } else { showValue = newDownVal; showValSpinner.setValue(TEN); } } - if(e.getActionCommand().equals("more")){ + if (e.getActionCommand().equals("more")) { int newUpVal = showValue + TEN; - if (newUpVal <= FOUR_HUNDRED ){ + if (newUpVal <= FOUR_HUNDRED) { showValue = newUpVal; showValSpinner.setValue(newUpVal); - }else { + } else { showValue = newUpVal; showValSpinner.setValue(FOUR_HUNDRED); } @@ -288,51 +289,49 @@ public class JFormSliderPane extends JPanel { }; - - private void getTimes(int value){ - if (value == HALF_HUNDRED){ - times=HUNDRED; - }else if (value < HALF_HUNDRED){ - times = (int) Math.round(ONEPOINTEIGHT*value + TEN); - }else { - times = (int) (SIX*value - TWO_HUNDRED); + private void getTimes(int value) { + if (value == HALF_HUNDRED) { + times = HUNDRED; + } else if (value < HALF_HUNDRED) { + times = (int) Math.round(ONEPOINTEIGHT * value + TEN); + } else { + times = (int) (SIX * value - TWO_HUNDRED); } } - public JSpinner getShowVal(){ + public JSpinner getShowVal() { return this.showValSpinner; } - public UIRadioButton getSelfAdaptButton(){ + public UIRadioButton getSelfAdaptButton() { return this.selfAdaptButton; } - private void popupDialog(){ + private void popupDialog() { Point btnCoords = upButton.getLocationOnScreen(); - if (dialog == null){ - dialog = new FormPopupPane(upButton,dialogContentPanel); + if (dialog == null) { + dialog = new FormPopupPane(upButton, dialogContentPanel); if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH , -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); } - }else { + } else { if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOG_WIDTH + upButton.getWidth() +SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); } else { - GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOG_WIDTH + upButton.getWidth() +SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); } } } - public static void main(String[] args) - { + public static void main(String[] args) { JFrame jf = new JFrame("test"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel)jf.getContentPane(); + JPanel content = (JPanel) jf.getContentPane(); content.setLayout(new BorderLayout()); - content.add(JFormSliderPane.getInstance(),BorderLayout.CENTER); + content.add(JFormSliderPane.getInstance(), BorderLayout.CENTER); GUICoreUtils.centerWindow(jf); jf.setSize(400, 80); jf.setVisible(true); @@ -349,17 +348,18 @@ class FormPopupPane extends JPopupMenu { private static final int UPLABEL_WIDTH = 300; private JComponent centerPane; private UILabel upLabel; - FormPopupPane(UIButton b,JPanel dialogContentPanel) { + + FormPopupPane(UIButton b, JPanel dialogContentPanel) { contentPane = new JPanel(new BorderLayout()); centerPane = new JPanel(new BorderLayout()); upLabel = new UILabel(" " + Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce")); upLabel.setOpaque(true); - upLabel.setPreferredSize(new Dimension(UPLABEL_WIDTH,UPLABEL_HEIGHT)); + upLabel.setPreferredSize(new Dimension(UPLABEL_WIDTH, UPLABEL_HEIGHT)); upLabel.setBackground(Color.LIGHT_GRAY); - upLabel.setBorder(new MatteBorder(0,0,1,0,Color.gray)); - centerPane.add(dialogContentPanel,BorderLayout.NORTH); - contentPane.add(upLabel,BorderLayout.NORTH); - contentPane.add(centerPane,BorderLayout.CENTER); + upLabel.setBorder(new MatteBorder(0, 0, 1, 0, Color.gray)); + centerPane.add(dialogContentPanel, BorderLayout.NORTH); + contentPane.add(upLabel, BorderLayout.NORTH); + contentPane.add(centerPane, BorderLayout.CENTER); // contentPane.setBorder(new MatteBorder(1,1,1,1,Color.darkGray)); this.add(contentPane, BorderLayout.CENTER); this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); diff --git a/designer_base/src/com/fr/design/mainframe/JSliderPane.java b/designer_base/src/com/fr/design/mainframe/JSliderPane.java index a14e10662..3feba5efa 100644 --- a/designer_base/src/com/fr/design/mainframe/JSliderPane.java +++ b/designer_base/src/com/fr/design/mainframe/JSliderPane.java @@ -18,7 +18,10 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.basic.BasicSliderUI; import java.awt.*; -import java.awt.event.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.math.BigDecimal; /** @@ -31,7 +34,7 @@ public class JSliderPane extends JPanel { private static final int TEN = 10; private static final int ONE_EIGHT = 18; private static final int FONT_SIZE = 14; - private static final int SPINNER_WIDTH= 45; + private static final int SPINNER_WIDTH = 45; private static final int SPINNER_HEIGHT = 20; private static final int HALF_HUNDRED = 50; private static final int HUNDRED = 100; @@ -69,7 +72,7 @@ public class JSliderPane extends JPanel { public JSliderPane() { this.setLayout(new BorderLayout()); - slider = new UISlider(0,HUNDRED,HALF_HUNDRED); + slider = new UISlider(0, HUNDRED, HALF_HUNDRED); slider.setUI(new JSliderPaneUI(slider)); slider.addChangeListener(listener); @@ -92,19 +95,19 @@ public class JSliderPane extends JPanel { downButton.addActionListener(buttonActionListener); upButton.addActionListener(buttonActionListener); - showValButton = new UIButton(showValSpinner.getValue()+"%"); + showValButton = new UIButton(showValSpinner.getValue() + "%"); showValButton.setBorderPainted(false); - showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH,SHOWVALBUTTON_HEIGHTH)); + showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); showValButton.addActionListener(showValButtonActionListener); initUIRadioButton(); initPane(); - JPanel panel = new JPanel(new FlowLayout(1,1,0)); + JPanel panel = new JPanel(new FlowLayout(1, 1, 0)); panel.add(downButton); panel.add(slider); panel.add(upButton); panel.add(showValButton); - this.add(panel,BorderLayout.NORTH); - this.setBounds(0,0,THREE_HUNDRED,ONE_EIGHT); + this.add(panel, BorderLayout.NORTH); + this.setBounds(0, 0, THREE_HUNDRED, ONE_EIGHT); } public static final JSliderPane getInstance() { @@ -115,7 +118,7 @@ public class JSliderPane extends JPanel { return THIS; } - private void initUIRadioButton(){ + private void initUIRadioButton() { twoHundredButton = new UIRadioButton("200%"); oneHundredButton = new UIRadioButton("100%"); SevenFiveButton = new UIRadioButton("75%"); @@ -131,7 +134,7 @@ public class JSliderPane extends JPanel { //TODO // selfAdaptButton.addItemListener(); - ButtonGroup bg=new ButtonGroup();// 初始化按钮组 + ButtonGroup bg = new ButtonGroup();// 初始化按钮组 bg.add(twoHundredButton);// 加入按钮组 bg.add(oneHundredButton); bg.add(SevenFiveButton); @@ -142,24 +145,24 @@ public class JSliderPane extends JPanel { customButton.setSelected(true); } - private void initPane(){ + private void initPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] columnSize = { p, f }; - double[] rowSize = { p,p,p,p,p,p,p}; + double[] columnSize = {p, f}; + double[] rowSize = {p, p, p, p, p, p, p}; Component[][] components = new Component[][]{ - new Component[]{twoHundredButton,null}, - new Component[]{oneHundredButton,null}, - new Component[]{SevenFiveButton,null}, - new Component[]{fiveTenButton,null}, - new Component[]{twoFiveButton,null}, - new Component[]{selfAdaptButton,null}, - new Component[]{customButton,createSpinnerPanel()} + new Component[]{twoHundredButton, null}, + new Component[]{oneHundredButton, null}, + new Component[]{SevenFiveButton, null}, + new Component[]{fiveTenButton, null}, + new Component[]{twoFiveButton, null}, + new Component[]{selfAdaptButton, null}, + new Component[]{customButton, createSpinnerPanel()} }; - dialogContentPanel = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); + dialogContentPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } - private JPanel createSpinnerPanel(){ + private JPanel createSpinnerPanel() { JPanel spinnerPanel = new JPanel(new FlowLayout()); spinnerPanel.add(showValSpinner); UILabel percent = new UILabel("%"); @@ -178,14 +181,14 @@ public class JSliderPane extends JPanel { ChangeListener showValSpinnerChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - int val = (int) ((UIBasicSpinner)e.getSource()).getValue(); + int val = (int) ((UIBasicSpinner) e.getSource()).getValue(); isButtonOrIsTxt = true; - resolutionTimes = divide(showValue,100,2); - if (val > FOUR_HUNDRED){ + resolutionTimes = divide(showValue, 100, 2); + if (val > FOUR_HUNDRED) { showValSpinner.setValue(FOUR_HUNDRED); val = FOUR_HUNDRED; } - if (val < TEN){ + if (val < TEN) { showValSpinner.setValue(TEN); val = TEN; } @@ -196,11 +199,10 @@ public class JSliderPane extends JPanel { //定义一个监听器,用于监听所有滑动条 - ChangeListener listener = new ChangeListener() - { - public void stateChanged( ChangeEvent event) { + ChangeListener listener = new ChangeListener() { + public void stateChanged(ChangeEvent event) { //取出滑动条的值,并在文本中显示出来 - if (!isButtonOrIsTxt){ + if (!isButtonOrIsTxt) { customButton.setSelected(true); EventQueue.invokeLater(new Runnable() { public void run() { @@ -210,50 +212,50 @@ public class JSliderPane extends JPanel { showValSpinner.setValue(times); } }); - }else { + } else { isButtonOrIsTxt = false; } } }; - ItemListener radioButtonItemListener = new ItemListener() { + ItemListener radioButtonItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - JRadioButton temp=(JRadioButton)e.getSource(); - if(temp.isSelected()){ + JRadioButton temp = (JRadioButton) e.getSource(); + if (temp.isSelected()) { showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%")))); } } }; - private void refreshSlider(int val){ + private void refreshSlider(int val) { showValue = val; - if (showValue >HUNDRED){ - slider.setValue((int)(showValue+TWO_HUNDRED)/SIX); - }else if (showValue HUNDRED) { + slider.setValue((int) (showValue + TWO_HUNDRED) / SIX); + } else if (showValue < HUNDRED) { + slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT)); + } else if (showValue == HUNDRED) { slider.setValue(HALF_HUNDRED); } } - private void refreshBottun(int val){ - showValButton.setText(val+"%"); + private void refreshBottun(int val) { + showValButton.setText(val + "%"); } - public double getResolutionTimes(){ + public double getResolutionTimes() { return this.resolutionTimes; } - public int getshowValue(){ + public int getshowValue() { return this.showValue; } - public static double divide(double v1, double v2,int scale) { + public static double divide(double v1, double v2, int scale) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); - return b1.divide(b2,scale).doubleValue(); + return b1.divide(b2, scale).doubleValue(); } ActionListener buttonActionListener = new ActionListener() { @@ -261,22 +263,22 @@ public class JSliderPane extends JPanel { public void actionPerformed(ActionEvent e) { showValue = (int) showValSpinner.getValue(); isButtonOrIsTxt = true; - if(e.getActionCommand().equals("less")){ + if (e.getActionCommand().equals("less")) { int newDownVal = showValue - TEN; - if (newDownVal >= TEN ){ + if (newDownVal >= TEN) { showValue = newDownVal; showValSpinner.setValue(newDownVal); - }else { + } else { showValue = newDownVal; showValSpinner.setValue(TEN); } } - if(e.getActionCommand().equals("more")){ + if (e.getActionCommand().equals("more")) { int newUpVal = showValue + TEN; - if (newUpVal <= FOUR_HUNDRED ){ + if (newUpVal <= FOUR_HUNDRED) { showValue = newUpVal; showValSpinner.setValue(newUpVal); - }else { + } else { showValue = newUpVal; showValSpinner.setValue(FOUR_HUNDRED); } @@ -287,51 +289,49 @@ public class JSliderPane extends JPanel { }; - - private void getTimes(int value){ - if (value == HALF_HUNDRED){ - times=HUNDRED; - }else if (value < HALF_HUNDRED){ - times = (int) Math.round(ONEPOINTEIGHT*value + TEN); - }else { - times = (int) (SIX*value - TWO_HUNDRED); + private void getTimes(int value) { + if (value == HALF_HUNDRED) { + times = HUNDRED; + } else if (value < HALF_HUNDRED) { + times = (int) Math.round(ONEPOINTEIGHT * value + TEN); + } else { + times = (int) (SIX * value - TWO_HUNDRED); } } - public JSpinner getShowVal(){ + public JSpinner getShowVal() { return this.showValSpinner; } - public UIRadioButton getSelfAdaptButton(){ + public UIRadioButton getSelfAdaptButton() { return this.selfAdaptButton; } - private void popupDialog(){ + private void popupDialog() { Point btnCoords = upButton.getLocationOnScreen(); - if (dialog == null){ - dialog = new PopupPane(upButton,dialogContentPanel); + if (dialog == null) { + dialog = new PopupPane(upButton, dialogContentPanel); if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH , -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); } - }else { + } else { if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOG_WIDTH + upButton.getWidth() +SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); } else { - GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOG_WIDTH + upButton.getWidth() +SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); } } } - public static void main(String[] args) - { + public static void main(String[] args) { JFrame jf = new JFrame("test"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel)jf.getContentPane(); + JPanel content = (JPanel) jf.getContentPane(); content.setLayout(new BorderLayout()); - content.add(JSliderPane.getInstance(),BorderLayout.CENTER); + content.add(JSliderPane.getInstance(), BorderLayout.CENTER); GUICoreUtils.centerWindow(jf); jf.setSize(400, 80); jf.setVisible(true); @@ -359,11 +359,10 @@ class JSliderPaneUI extends BasicSliderUI { public Dimension getThumbSize() { Dimension size = new Dimension(); - if ( slider.getOrientation() == JSlider.VERTICAL ) { + if (slider.getOrientation() == JSlider.VERTICAL) { size.width = VERTICAL_WIDTH; size.height = VERTICAL_HEIGHT; - } - else { + } else { size.width = VERTICAL_WIDTH; size.height = VERTICAL_HEIGHT; } @@ -377,14 +376,13 @@ class JSliderPaneUI extends BasicSliderUI { int h = knobBounds.height; g.translate(knobBounds.x, knobBounds.y); - if ( slider.isEnabled() ) { + if (slider.isEnabled()) { g.setColor(slider.getBackground()); - } - else { + } else { g.setColor(slider.getBackground().darker()); } g.setColor(Color.darkGray); - g.fillRect(0, 1, w-SIX, h+1); + g.fillRect(0, 1, w - SIX, h + 1); } /** */ @@ -399,8 +397,8 @@ class JSliderPaneUI extends BasicSliderUI { cy = (trackBounds.height / 2); cw = trackBounds.width; g.setColor(Color.lightGray); - g.drawLine(0, cy, cw+FIVE, cy); - g.drawLine(FIVE+cw/2, cy-FOUR, FIVE+cw/2, cy+FOUR); + g.drawLine(0, cy, cw + FIVE, cy); + g.drawLine(FIVE + cw / 2, cy - FOUR, FIVE + cw / 2, cy + FOUR); } else { super.paintTrack(g); } @@ -416,17 +414,18 @@ class PopupPane extends JPopupMenu { private static final int UPLABEL_WIDTH = 300; private JComponent centerPane; private UILabel upLabel; - PopupPane(UIButton b,JPanel dialogContentPanel) { + + PopupPane(UIButton b, JPanel dialogContentPanel) { contentPane = new JPanel(new BorderLayout()); centerPane = new JPanel(new BorderLayout()); upLabel = new UILabel(" " + Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce")); upLabel.setOpaque(true); - upLabel.setPreferredSize(new Dimension(UPLABEL_WIDTH,UPLABEL_HEIGHT)); + upLabel.setPreferredSize(new Dimension(UPLABEL_WIDTH, UPLABEL_HEIGHT)); upLabel.setBackground(Color.LIGHT_GRAY); - upLabel.setBorder(new MatteBorder(0,0,1,0,Color.gray)); - centerPane.add(dialogContentPanel,BorderLayout.NORTH); - contentPane.add(upLabel,BorderLayout.NORTH); - contentPane.add(centerPane,BorderLayout.CENTER); + upLabel.setBorder(new MatteBorder(0, 0, 1, 0, Color.gray)); + centerPane.add(dialogContentPanel, BorderLayout.NORTH); + contentPane.add(upLabel, BorderLayout.NORTH); + contentPane.add(centerPane, BorderLayout.CENTER); // contentPane.setBorder(new MatteBorder(1,1,1,1,Color.darkGray)); this.add(contentPane, BorderLayout.CENTER); this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); @@ -434,5 +433,4 @@ class PopupPane extends JPopupMenu { } - } \ No newline at end of file