forked from fanruan/design
yaoh.wu
8 years ago
10 changed files with 161 additions and 123 deletions
@ -1,93 +1,96 @@ |
|||||||
package com.fr.design.designer.beans.painters; |
package com.fr.design.designer.beans.painters; |
||||||
|
|
||||||
import java.awt.Color; |
import java.awt.Color; |
||||||
import java.awt.Graphics; |
import java.awt.Graphics; |
||||||
import java.awt.Graphics2D; |
import java.awt.Graphics2D; |
||||||
import java.awt.Point; |
import java.awt.Point; |
||||||
import java.awt.Rectangle; |
import java.awt.Rectangle; |
||||||
import java.awt.Stroke; |
import java.awt.Stroke; |
||||||
|
|
||||||
import com.fr.design.designer.beans.HoverPainter; |
import com.fr.design.designer.beans.HoverPainter; |
||||||
import com.fr.design.designer.creator.XCreator; |
import com.fr.design.designer.creator.XCreator; |
||||||
import com.fr.design.designer.creator.XLayoutContainer; |
import com.fr.design.designer.creator.XLayoutContainer; |
||||||
import com.fr.design.form.util.XCreatorConstants; |
import com.fr.design.form.util.XCreatorConstants; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
|
|
||||||
public abstract class AbstractPainter implements HoverPainter { |
public abstract class AbstractPainter implements HoverPainter { |
||||||
|
|
||||||
protected Point hotspot; |
protected Point hotspot; |
||||||
protected Rectangle hotspot_bounds; |
protected Rectangle hotspot_bounds; |
||||||
protected XLayoutContainer container; |
protected XLayoutContainer container; |
||||||
protected XCreator creator; |
protected XCreator creator; |
||||||
|
|
||||||
/** |
/** |
||||||
* 构造函数 |
* 构造函数 |
||||||
* @param container 容器 |
* |
||||||
*/ |
* @param container 容器 |
||||||
public AbstractPainter(XLayoutContainer container) { |
*/ |
||||||
this.container = container; |
public AbstractPainter(XLayoutContainer container) { |
||||||
} |
this.container = container; |
||||||
|
} |
||||||
@Override |
|
||||||
public void setHotspot(Point p) { |
@Override |
||||||
hotspot = p; |
public void setHotspot(Point p) { |
||||||
} |
hotspot = p; |
||||||
|
} |
||||||
/** |
|
||||||
* 画初始区域 |
/** |
||||||
* @param g 画图类 |
* 画初始区域 |
||||||
* @param startX 起始x位置 |
* |
||||||
* @param startY 起始y位置 |
* @param g 画图类 |
||||||
*/ |
* @param startX 起始x位置 |
||||||
public void paint(Graphics g, int startX, int startY) { |
* @param startY 起始y位置 |
||||||
if(hotspot_bounds != null){ |
*/ |
||||||
drawHotspot(g, hotspot_bounds.x, hotspot_bounds.y, hotspot_bounds.width, hotspot_bounds.height, Color.lightGray, true, false); |
public void paint(Graphics g, int startX, int startY) { |
||||||
} |
if (hotspot_bounds != null) { |
||||||
} |
drawHotspot(g, hotspot_bounds.x, hotspot_bounds.y, hotspot_bounds.width, hotspot_bounds.height, Color.lightGray, true, false); |
||||||
|
} |
||||||
/** |
} |
||||||
* 设置边界 |
|
||||||
* @param rect 位置 |
/** |
||||||
*/ |
* 设置边界 |
||||||
@Override |
* |
||||||
public void setRenderingBounds(Rectangle rect) { |
* @param rect 位置 |
||||||
hotspot_bounds = rect; |
*/ |
||||||
} |
@Override |
||||||
|
public void setRenderingBounds(Rectangle rect) { |
||||||
@Override |
hotspot_bounds = rect; |
||||||
public void setCreator(XCreator component) { |
} |
||||||
this.creator = component; |
|
||||||
} |
@Override |
||||||
|
public void setCreator(XCreator component) { |
||||||
protected void drawHotspot(Graphics g, int x, int y, int width, int height, boolean accept) { |
this.creator = component; |
||||||
Color bColor = accept ? XCreatorConstants.LAYOUT_HOTSPOT_COLOR : XCreatorConstants.LAYOUT_FORBIDDEN_COLOR; |
} |
||||||
drawHotspot(g, x, y, width, height, bColor, accept, false); |
|
||||||
} |
protected void drawHotspot(Graphics g, int x, int y, int width, int height, boolean accept) { |
||||||
|
Color bColor = accept ? XCreatorConstants.LAYOUT_HOTSPOT_COLOR : XCreatorConstants.LAYOUT_FORBIDDEN_COLOR; |
||||||
/** |
drawHotspot(g, x, y, width, height, bColor, accept, false); |
||||||
* 自适应布局那边渲染提示,要画整个背景,不是画边框 |
} |
||||||
*/ |
|
||||||
protected void drawRegionBackground(Graphics g, int x, int y, int width, int height, Color bColor, boolean accept) { |
/** |
||||||
drawHotspot(g, x, y, width, height, bColor, accept, true); |
* 自适应布局那边渲染提示,要画整个背景,不是画边框 |
||||||
} |
*/ |
||||||
|
protected void drawRegionBackground(Graphics g, int x, int y, int width, int height, Color bColor, boolean accept) { |
||||||
protected void drawHotspot(Graphics g, int x, int y, int width, int height, Color bColor, boolean accept, boolean drawBackground) { |
drawHotspot(g, x, y, width, height, bColor, accept, true); |
||||||
Graphics2D g2d = (Graphics2D) g; |
} |
||||||
Color color = g2d.getColor(); |
|
||||||
Stroke backup = g2d.getStroke(); |
protected void drawHotspot(Graphics g, int x, int y, int width, int height, Color bColor, boolean accept, boolean drawBackground) { |
||||||
// 设置线条的样式
|
Graphics2D g2d = (Graphics2D) g; |
||||||
g2d.setStroke(XCreatorConstants.STROKE); |
Color color = g2d.getColor(); |
||||||
g2d.setColor(bColor); |
Stroke backup = g2d.getStroke(); |
||||||
if (!accept) { |
// 设置线条的样式
|
||||||
g2d.drawString(Inter.getLocText("Cannot-Add_To_This_Area") + "!", x + width / 3, y + height / 2); |
g2d.setStroke(XCreatorConstants.STROKE); |
||||||
} else if (drawBackground) { |
g2d.setColor(bColor); |
||||||
g2d.fillRect(x, y, width, height); |
if (!accept) { |
||||||
} else { |
g2d.drawString(Inter.getLocText("Cannot-Add_To_This_Area") + "!", x + width / 3, y + height / 2); |
||||||
g2d.drawRect(x, y, width, height); |
} else if (drawBackground) { |
||||||
} |
g2d.fillRect(x, y, width, height); |
||||||
g2d.setStroke(backup); |
} else { |
||||||
g2d.setColor(color); |
g2d.drawRect(x, y, width, height); |
||||||
} |
} |
||||||
|
g2d.setStroke(backup); |
||||||
|
g2d.setColor(color); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
} |
} |
Loading…
Reference in new issue