Before Width: | Height: | Size: 418 B |
Before Width: | Height: | Size: 372 B |
Before Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 369 B |
Before Width: | Height: | Size: 237 B |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 14 KiB |
@ -1 +1 @@ |
|||||||
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: 345 B |
Before Width: | Height: | Size: 349 B |
Before Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 165 B |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 191 B |
Before Width: | Height: | Size: 191 B |
Before Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 623 B |
Before Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 667 B |
Before Width: | Height: | Size: 624 B |
Before Width: | Height: | Size: 639 B |
Before Width: | Height: | Size: 380 B |
Before Width: | Height: | Size: 363 B |
Before Width: | Height: | Size: 373 B |
Before Width: | Height: | Size: 156 B |
Before Width: | Height: | Size: 156 B |
Before Width: | Height: | Size: 156 B |
Before Width: | Height: | Size: 344 B |
Before Width: | Height: | Size: 352 B |
Before Width: | Height: | Size: 361 B |
Before Width: | Height: | Size: 574 B |
Before Width: | Height: | Size: 542 B |
Before Width: | Height: | Size: 559 B |
Before Width: | Height: | Size: 135 B |
Before Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 708 B |
Before Width: | Height: | Size: 740 B |
Before Width: | Height: | Size: 729 B |
Before Width: | Height: | Size: 619 B |
Before Width: | Height: | Size: 614 B |
Before Width: | Height: | Size: 628 B |
Before Width: | Height: | Size: 394 B |
Before Width: | Height: | Size: 393 B |
Before Width: | Height: | Size: 408 B |
Before Width: | Height: | Size: 460 B |
Before Width: | Height: | Size: 458 B |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 210 B |
Before Width: | Height: | Size: 251 B |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 303 B After Width: | Height: | Size: 388 B |
Before Width: | Height: | Size: 694 B After Width: | Height: | Size: 300 B |
Before Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 533 B |
Before Width: | Height: | Size: 706 B After Width: | Height: | Size: 285 B |
Before Width: | Height: | Size: 384 B |
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 250 B |
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 264 B |
Before Width: | Height: | Size: 265 B After Width: | Height: | Size: 193 B |
Before Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 272 B After Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 273 B |
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 255 B |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 213 B |
Before Width: | Height: | Size: 316 B |
Before Width: | Height: | Size: 291 B |
Before Width: | Height: | Size: 318 B |
Before Width: | Height: | Size: 291 B |
Before Width: | Height: | Size: 492 B |
Before Width: | Height: | Size: 1.2 KiB |