From c285851e1542942f14501970529200d495d623a0 Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 2 Aug 2017 11:23:40 +0800 Subject: [PATCH] 9 --- .../fr/design/file/MutilTempalteTabPane.java | 38 +-- .../fr/design/gui/ibutton/UIHeadGroup.java | 256 +++++++++--------- 2 files changed, 144 insertions(+), 150 deletions(-) diff --git a/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java b/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java index 264502d02..4b461b1ec 100644 --- a/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java @@ -364,14 +364,15 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M generalPath.moveTo((float) templateStartX, getHeight() - 1); generalPath.lineTo((float) maxWidth, getHeight() - 1); g2d.fill(generalPath); - g2d.setPaint(UIConstants.LINE_COLOR); - g2d.draw(new Line2D.Double((float) templateStartX, getHeight() - 1, (float) maxWidth + LIST_BUTTON_WIDTH, getHeight() - 1)); + //TODO hzzz delete +// g2d.setPaint(UIConstants.LINE_COLOR); +// g2d.draw(new Line2D.Double((float) templateStartX, getHeight() - 1, (float) maxWidth + LIST_BUTTON_WIDTH, getHeight() - 1)); } } private void paintDefaultBackground(Graphics2D g2d) { //画默认背景 - g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, getHeight() - 1, UIConstants.SHADOW_GREY)); + g2d.setPaint(new GradientPaint(1, 1, new Color(217, 218, 221), 1, getHeight() - 1, new Color(217, 218, 221))); g2d.fillRect(getX(), getY(), getWidth(), getHeight()); } @@ -497,7 +498,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX}; double[] y = {-1, getHeight(), getHeight(), -1, -1}; RoundRectangle2D.Double rect1 = new RoundRectangle2D.Double(templateStartX, 1, this.getWidth(), this.getHeight(), 7, 7); - g2d.setPaint(new GradientPaint(1, 1, UIConstants.NORMAL_BACKGROUND, 1, getHeight() - 1, UIConstants.NORMAL_BACKGROUND)); + g2d.setPaint(new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, getHeight() - 1, UIConstants.SELECT_TAB)); //选了30度和60度的特殊角度的x,y作为经过的两个点的坐标 double specialLocation1 = 2.5; double specialLocation2 = 4.330127; @@ -561,21 +562,22 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M unSelectedClosedPath(generalPath, isLeft, x, y); g2d.fill(generalPath); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setPaint(UIConstants.LINE_COLOR); - if (isLeft) { - g2d.draw(new Arc2D.Double(x[0], y[0], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, 90, 0)); - } else { - g2d.draw(new Arc2D.Double(x[0] - CORNOR_RADIUS * 2, y[0], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, -90, 0)); - } - - g2d.draw(new Line2D.Double(x[0], y[0] + CORNOR_RADIUS, x[1], y[1] + 1)); - g2d.draw(new Line2D.Double(x[1], y[1], x[2], y[2])); + g2d.setPaint(new Color(200, 201, 205)); + //TODO hzzz delete +// if (isLeft) { +// g2d.draw(new Arc2D.Double(x[0], y[0], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, 90, 0)); +// } else { +// g2d.draw(new Arc2D.Double(x[0] - CORNOR_RADIUS * 2, y[0], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, -90, 0)); +// } + +// g2d.draw(new Line2D.Double(x[0], y[0] + CORNOR_RADIUS, x[1], y[1] + 1)); +// g2d.draw(new Line2D.Double(x[1], y[1], x[2], y[2])); g2d.draw(new Line2D.Double(x[2], y[2], x[3], y[3] + CORNOR_RADIUS)); - if (isLeft) { - g2d.draw(new Arc2D.Double(x[3], y[3], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, 90, 0)); - } else { - g2d.draw(new Arc2D.Double(x[3] - CORNOR_RADIUS * 2, y[3], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, -90, 0)); - } +// if (isLeft) { +// g2d.draw(new Arc2D.Double(x[3], y[3], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, 90, 0)); +// } else { +// g2d.draw(new Arc2D.Double(x[3] - CORNOR_RADIUS * 2, y[3], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, -90, 0)); +// } g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); int sheetIconY = (getHeight() - sheeticon.getIconHeight()) / 2; diff --git a/designer_base/src/com/fr/design/gui/ibutton/UIHeadGroup.java b/designer_base/src/com/fr/design/gui/ibutton/UIHeadGroup.java index 85eb1e6ea..3e7c488c1 100644 --- a/designer_base/src/com/fr/design/gui/ibutton/UIHeadGroup.java +++ b/designer_base/src/com/fr/design/gui/ibutton/UIHeadGroup.java @@ -1,89 +1,81 @@ package com.fr.design.gui.ibutton; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.GridLayout; +import com.fr.base.BaseUtils; +import com.fr.design.constants.UIConstants; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.*; +import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.ArrayList; import java.util.List; -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JFrame; -import javax.swing.JPanel; +public class UIHeadGroup extends JPanel { + protected List labelButtonList; + private boolean isNeedLeftRightOutLine = true; + protected int selectedIndex = -1; -import com.fr.base.BaseUtils; -import com.fr.design.constants.UIConstants; -import com.fr.design.utils.gui.GUICoreUtils; + protected void tabChanged(int newSelectedIndex) { + + } -public class UIHeadGroup extends JPanel{ - protected List labelButtonList; - private boolean isNeedLeftRightOutLine = true; - protected int selectedIndex = -1; - - protected void tabChanged(int newSelectedIndex) { - - } - - public UIHeadGroup(String[] textArray) { - labelButtonList = new ArrayList(textArray.length); - this.setBackground(UIConstants.NORMAL_BACKGROUND); - this.setLayout(new GridLayout(0, textArray.length, 1, 0)); - this.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); - for(int i = 0; i < textArray.length; i++) { - final int index = i; - String text = textArray[i]; - final UIToggleButton labelButton = new UIToggleButton(text) { - @Override - protected MouseListener getMouseListener() { - return new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - setSelectedIndex(index); - UIHeadGroup.this.repaint(); - } - }; - } - }; - initButton(labelButton); - } - setSelectedIndex(0); - } - - public UIHeadGroup(Icon[] iconArray) { - labelButtonList = new ArrayList(iconArray.length); - this.setBackground(UIConstants.NORMAL_BACKGROUND); - this.setLayout(new GridLayout(0, iconArray.length, 1, 0)); - this.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); - for(int i = 0; i < iconArray.length; i++) { - final int index = i; - Icon icon = iconArray[i]; - final UIToggleButton labelButton = new UIToggleButton(icon) { - @Override - protected MouseListener getMouseListener() { - return new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - setSelectedIndex(index); - UIHeadGroup.this.repaint(); - } - }; - } - }; - initButton(labelButton); - } - setSelectedIndex(0); - } + public UIHeadGroup(String[] textArray) { + labelButtonList = new ArrayList(textArray.length); + this.setBackground(UIConstants.NORMAL_BACKGROUND); + this.setLayout(new GridLayout(0, textArray.length, 1, 0)); +// this.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); + for (int i = 0; i < textArray.length; i++) { + final int index = i; + String text = textArray[i]; + final UIToggleButton labelButton = new UIToggleButton(text) { + @Override + protected MouseListener getMouseListener() { + return new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + setSelectedIndex(index); + UIHeadGroup.this.repaint(); + } + }; + } + }; + initButton(labelButton); + } + setSelectedIndex(0); + } + + public UIHeadGroup(Icon[] iconArray) { + labelButtonList = new ArrayList(iconArray.length); + this.setBackground(UIConstants.NORMAL_BACKGROUND); + this.setLayout(new GridLayout(0, iconArray.length, 1, 0)); +// this.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); + for (int i = 0; i < iconArray.length; i++) { + final int index = i; + Icon icon = iconArray[i]; + final UIToggleButton labelButton = new UIToggleButton(icon) { + @Override + protected MouseListener getMouseListener() { + return new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + setSelectedIndex(index); + UIHeadGroup.this.repaint(); + } + }; + } + }; + initButton(labelButton); + } + setSelectedIndex(0); + } public UIHeadGroup(Icon[] iconArray, String[] textArray) { labelButtonList = new ArrayList(Math.min(textArray.length, iconArray.length)); this.setBackground(UIConstants.NORMAL_BACKGROUND); this.setLayout(new GridLayout(0, textArray.length, 1, 0)); - this.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); - for(int i = 0; i < textArray.length; i++) { + for (int i = 0; i < textArray.length; i++) { final int index = i; String text = textArray[i]; Icon icon = iconArray[i]; @@ -104,15 +96,15 @@ public class UIHeadGroup extends JPanel{ setSelectedIndex(0); } - @Override - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - dim.height = 25; - return dim; - } - - @Override - protected void paintBorder(Graphics g) { + @Override + public Dimension getPreferredSize() { + Dimension dim = super.getPreferredSize(); + dim.height = 25; + return dim; + } + + @Override + protected void paintBorder(Graphics g) { // Graphics2D g2d = (Graphics2D)g; // g2d.setColor(UIConstants.LINE_COLOR); // @@ -135,56 +127,56 @@ public class UIHeadGroup extends JPanel{ // g2d.setColor(UIConstants.NORMAL_BACKGROUND); // UIToggleButton headButton = labelButtonList.get(selectedIndex); // g2d.drawLine(headButton.getX(), headButton.getHeight() + 1, headButton.getX() + headButton.getWidth() - 1, headButton.getHeight() + 1); - } - - private void initButton(UIToggleButton labelButton) { - labelButton.setRoundBorder(false); - labelButton.setBorderPainted(false); - labelButton.setPressedPainted(false); - labelButtonList.add(labelButton); - this.add(labelButton); - } - - public void setSelectedIndex(int newSelectedIndex) { - selectedIndex = newSelectedIndex; - for (int i = 0; i < labelButtonList.size(); i++) { - UIToggleButton button = labelButtonList.get(i); - if(i == selectedIndex) { - button.setNormalPainted(false); - button.setOpaque(true); - button.setBackground(null); - button.setSelected(true); - } else { - button.setOpaque(false); - button.setNormalPainted(true); - button.setSelected(false); - } - } - - tabChanged(newSelectedIndex); - } - - public void setNeedLeftRightOutLine(boolean isNeedLeftRightOutLine) { - this.isNeedLeftRightOutLine = isNeedLeftRightOutLine; - } - - public int getSelectedIndex() { - return selectedIndex; - } - - public static void main(String... args) { - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel)jf.getContentPane(); - content.setLayout(null); - Icon[] a1 = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), - BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png")}; - UIHeadGroup bb = new UIHeadGroup(a1); - bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height); - bb.setSelectedIndex(0); - content.add(bb); - GUICoreUtils.centerWindow(jf); - jf.setSize(400, 400); - jf.setVisible(true); - } + } + + private void initButton(UIToggleButton labelButton) { + labelButton.setRoundBorder(false); + labelButton.setBorderPainted(false); + labelButton.setPressedPainted(false); + labelButtonList.add(labelButton); + this.add(labelButton); + } + + public void setSelectedIndex(int newSelectedIndex) { + selectedIndex = newSelectedIndex; + for (int i = 0; i < labelButtonList.size(); i++) { + UIToggleButton button = labelButtonList.get(i); + if (i == selectedIndex) { + button.setNormalPainted(false); + button.setBackground(new Color(240, 240, 243)); + button.setOpaque(true); + button.setSelected(true); + } else { + button.setOpaque(false); + button.setNormalPainted(true); + button.setSelected(false); + } + } + + tabChanged(newSelectedIndex); + } + + public void setNeedLeftRightOutLine(boolean isNeedLeftRightOutLine) { + this.isNeedLeftRightOutLine = isNeedLeftRightOutLine; + } + + public int getSelectedIndex() { + return selectedIndex; + } + + public static void main(String... args) { + JFrame jf = new JFrame("test"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JPanel content = (JPanel) jf.getContentPane(); + content.setLayout(null); + Icon[] a1 = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), + BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png")}; + UIHeadGroup bb = new UIHeadGroup(a1); + bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height); + bb.setSelectedIndex(0); + content.add(bb); + GUICoreUtils.centerWindow(jf); + jf.setSize(400, 400); + jf.setVisible(true); + } } \ No newline at end of file