* commit '7c734e68b4b0100f9f6d7a066eb98571c54181b4': (27 commits) btn group border btn group image error scroll bar color format img img reset HEAD^1 remove unused img toolbar menu dock background format grid column and row background right background 10 9 format format “ tab pane color tab pane font color ...master
@ -1 +1,161 @@
|
||||
package com.fr.design.file;
import com.fr.base.BaseUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.DesignerContext;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
/**
* Author : daisy
* Date: 13-8-27
* Time: 下午6:07
*/
public abstract class NewTemplatePane extends JComponent implements MouseListener, MouseMotionListener {
private static final Icon GRAY_NEW_CPT = BaseUtils.readIcon("/com/fr/design/images/buttonicon/additicon_grey.png");
private static final int PRE_GAP = 0;
private static final int HEIGHT = 26;
private Graphics2D g2d;
private Icon newWorkBookIconMode = null;
private int newIconStartX = PRE_GAP;
public NewTemplatePane() {
newWorkBookIconMode = getNew();
this.setLayout(new BorderLayout(0, 0));
this.addMouseListener(this);
this.addMouseMotionListener(this);
this.setBorder(null);
this.setForeground(new Color(99, 99, 99));
}
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.width = HEIGHT;
return dim;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g2d = (Graphics2D) g;
int sheetIconY = (getHeight() - newWorkBookIconMode.getIconHeight()) / 2;
newWorkBookIconMode.paintIcon(this, g2d, newIconStartX, sheetIconY);
paintUnderLine(g2d);
}
private void paintUnderLine(Graphics2D g2d) {
//画下面的那条线
g2d.setPaint(UIConstants.LINE_COLOR);
g2d.draw(new Line2D.Double((float) 0, (float) (getHeight()-1), getWidth(), (float) (getHeight()-1)));
}
/**
*鼠标点击
* @param e 事件
*/
public void mouseClicked(MouseEvent e) {
if (BaseUtils.isAuthorityEditing()) {
newWorkBookIconMode = GRAY_NEW_CPT;
}
}
/**
*鼠标按下
* @param e 事件
*/
public void mousePressed(MouseEvent e) {
int evtX = e.getX();
if (BaseUtils.isAuthorityEditing()) {
newWorkBookIconMode = GRAY_NEW_CPT;
}
if (isOverNewIcon(evtX) && newWorkBookIconMode != GRAY_NEW_CPT) {
newWorkBookIconMode = getMousePressNew();
newIconStartX = 0;
DesignerContext.getDesignerFrame().addAndActivateJTemplate();
}
this.repaint();
}
/**
*鼠标松开
* @param e 事件
*/
public void mouseReleased(MouseEvent e) {
if (BaseUtils.isAuthorityEditing()) {
newWorkBookIconMode = GRAY_NEW_CPT;
}
}
/**
*鼠标进入
* @param e 事件
*/
public void mouseEntered(MouseEvent e) {
if (BaseUtils.isAuthorityEditing()) {
newWorkBookIconMode = GRAY_NEW_CPT;
}
}
/**
*鼠标离开
* @param e 事件
*/
public void mouseExited(MouseEvent e) {
newIconStartX = PRE_GAP;
if (BaseUtils.isAuthorityEditing()) {
newWorkBookIconMode = GRAY_NEW_CPT;
} else {
newWorkBookIconMode = getNew();
}
this.repaint();
}
/**
*鼠标拖拽
* @param e 事件
*/
public void mouseDragged(MouseEvent e) {
}
/**
*鼠标移动
* @param e 事件
*/
public void mouseMoved(MouseEvent e) {
int evtX = e.getX();
if (BaseUtils.isAuthorityEditing()) {
newWorkBookIconMode = GRAY_NEW_CPT;
} else if (isOverNewIcon(evtX)) {
newIconStartX = 0;
newWorkBookIconMode = getMouseOverNew();
}
this.repaint();
}
private boolean isOverNewIcon(int evtX) {
return (evtX >= PRE_GAP && evtX <= PRE_GAP + newWorkBookIconMode.getIconWidth());
}
public void setButtonGray(boolean isGray) {
newWorkBookIconMode = isGray ? GRAY_NEW_CPT : getNew();
}
public abstract Icon getNew();
public abstract Icon getMouseOverNew();
public abstract Icon getMousePressNew();
} |
||||
package com.fr.design.file; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseListener; |
||||
import java.awt.event.MouseMotionListener; |
||||
import java.awt.geom.Line2D; |
||||
|
||||
/** |
||||
* Author : daisy |
||||
* Date: 13-8-27 |
||||
* Time: 下午6:07 |
||||
*/ |
||||
public abstract class NewTemplatePane extends JComponent implements MouseListener, MouseMotionListener { |
||||
|
||||
private static final Icon GRAY_NEW_CPT = BaseUtils.readIcon("/com/fr/design/images/buttonicon/additicon_grey.png"); |
||||
private static final int PRE_GAP = 0; |
||||
private static final int HEIGHT = 26; |
||||
private Graphics2D g2d; |
||||
private Icon newWorkBookIconMode = null; |
||||
private int newIconStartX = PRE_GAP; |
||||
|
||||
|
||||
public NewTemplatePane() { |
||||
newWorkBookIconMode = getNew(); |
||||
this.setLayout(new BorderLayout(0, 0)); |
||||
this.addMouseListener(this); |
||||
this.addMouseMotionListener(this); |
||||
this.setBorder(null); |
||||
this.setForeground(new Color(99, 99, 99)); |
||||
} |
||||
|
||||
public Dimension getPreferredSize() { |
||||
Dimension dim = super.getPreferredSize(); |
||||
dim.width = HEIGHT; |
||||
return dim; |
||||
} |
||||
|
||||
|
||||
public void paintComponent(Graphics g) { |
||||
super.paintComponent(g); |
||||
g2d = (Graphics2D) g; |
||||
int sheetIconY = (getHeight() - newWorkBookIconMode.getIconHeight()) / 2; |
||||
newWorkBookIconMode.paintIcon(this, g2d, newIconStartX, sheetIconY); |
||||
// paintUnderLine(g2d);
|
||||
} |
||||
|
||||
|
||||
private void paintUnderLine(Graphics2D g2d) { |
||||
//画下面的那条线
|
||||
g2d.setPaint(UIConstants.LINE_COLOR); |
||||
g2d.draw(new Line2D.Double((float) 0, (float) (getHeight()-1), getWidth(), (float) (getHeight()-1))); |
||||
} |
||||
|
||||
/** |
||||
*鼠标点击 |
||||
* @param e 事件 |
||||
*/ |
||||
public void mouseClicked(MouseEvent e) { |
||||
if (BaseUtils.isAuthorityEditing()) { |
||||
newWorkBookIconMode = GRAY_NEW_CPT; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
*鼠标按下 |
||||
* @param e 事件 |
||||
*/ |
||||
public void mousePressed(MouseEvent e) { |
||||
int evtX = e.getX(); |
||||
if (BaseUtils.isAuthorityEditing()) { |
||||
newWorkBookIconMode = GRAY_NEW_CPT; |
||||
} |
||||
if (isOverNewIcon(evtX) && newWorkBookIconMode != GRAY_NEW_CPT) { |
||||
newWorkBookIconMode = getMousePressNew(); |
||||
newIconStartX = 0; |
||||
DesignerContext.getDesignerFrame().addAndActivateJTemplate(); |
||||
} |
||||
this.repaint(); |
||||
} |
||||
|
||||
/** |
||||
*鼠标松开 |
||||
* @param e 事件 |
||||
*/ |
||||
public void mouseReleased(MouseEvent e) { |
||||
if (BaseUtils.isAuthorityEditing()) { |
||||
newWorkBookIconMode = GRAY_NEW_CPT; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
*鼠标进入 |
||||
* @param e 事件 |
||||
*/ |
||||
public void mouseEntered(MouseEvent e) { |
||||
if (BaseUtils.isAuthorityEditing()) { |
||||
newWorkBookIconMode = GRAY_NEW_CPT; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
*鼠标离开 |
||||
* @param e 事件 |
||||
*/ |
||||
public void mouseExited(MouseEvent e) { |
||||
newIconStartX = PRE_GAP; |
||||
if (BaseUtils.isAuthorityEditing()) { |
||||
newWorkBookIconMode = GRAY_NEW_CPT; |
||||
} else { |
||||
newWorkBookIconMode = getNew(); |
||||
} |
||||
|
||||
this.repaint(); |
||||
} |
||||
|
||||
/** |
||||
*鼠标拖拽 |
||||
* @param e 事件 |
||||
*/ |
||||
public void mouseDragged(MouseEvent e) { |
||||
} |
||||
|
||||
/** |
||||
*鼠标移动 |
||||
* @param e 事件 |
||||
*/ |
||||
public void mouseMoved(MouseEvent e) { |
||||
int evtX = e.getX(); |
||||
if (BaseUtils.isAuthorityEditing()) { |
||||
newWorkBookIconMode = GRAY_NEW_CPT; |
||||
} else if (isOverNewIcon(evtX)) { |
||||
newIconStartX = 0; |
||||
newWorkBookIconMode = getMouseOverNew(); |
||||
} |
||||
|
||||
this.repaint(); |
||||
|
||||
} |
||||
|
||||
|
||||
private boolean isOverNewIcon(int evtX) { |
||||
return (evtX >= PRE_GAP && evtX <= PRE_GAP + newWorkBookIconMode.getIconWidth()); |
||||
} |
||||
|
||||
public void setButtonGray(boolean isGray) { |
||||
newWorkBookIconMode = isGray ? GRAY_NEW_CPT : getNew(); |
||||
} |
||||
|
||||
public abstract Icon getNew(); |
||||
|
||||
public abstract Icon getMouseOverNew(); |
||||
|
||||
public abstract Icon getMousePressNew(); |
||||
|
||||
} |
Before Width: | Height: | Size: 275 B After Width: | Height: | Size: 453 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 216 B |
Before Width: | Height: | Size: 515 B After Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 553 B After Width: | Height: | Size: 695 B |
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 412 B |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 191 B |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 191 B |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 823 B After Width: | Height: | Size: 623 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 159 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 166 B |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 259 B |
Before Width: | Height: | Size: 325 B After Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 404 B After Width: | Height: | Size: 439 B |
Before Width: | Height: | Size: 431 B After Width: | Height: | Size: 688 B |
Before Width: | Height: | Size: 432 B After Width: | Height: | Size: 514 B |
Before Width: | Height: | Size: 338 B After Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 469 B After Width: | Height: | Size: 700 B |
Before Width: | Height: | Size: 542 B After Width: | Height: | Size: 675 B |
Before Width: | Height: | Size: 659 B After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 759 B After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1020 B After Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 121 B |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 481 B |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 463 B |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 532 B |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 473 B |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 559 B |
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 359 B |
Before Width: | Height: | Size: 491 B After Width: | Height: | Size: 739 B |
Before Width: | Height: | Size: 415 B After Width: | Height: | Size: 414 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 388 B |
Before Width: | Height: | Size: 166 B After Width: | Height: | Size: 169 B |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 589 B |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 139 B |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 396 B |
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 424 B |
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 533 B |
Before Width: | Height: | Size: 218 B After Width: | Height: | Size: 231 B |