📄 jfchord.java
字号:
/**
* $Id:JFChord.java $
*
* Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All rights reserved. *
*/
package com.jfimagine.jfgraph.shape.arc;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.GeneralPath;
import com.jfimagine.jfgraph.geom.JFPoint;
import com.jfimagine.jfgraph.geom.Arc;
import com.jfimagine.jfgraph.geom.Rect;
import com.jfimagine.jfgraph.geom.JFArcPoint;
import com.jfimagine.jfgraph.shape.base.Port;
import com.jfimagine.jfgraph.shape.base.ShapeConst;
import com.jfimagine.jfgraph.shape.base.AbstractObject;
import com.jfimagine.jfgraph.shape.arc.AbstractArc;
import com.jfimagine.jfgraph.shape.decorate.Arrow;
/**
* JFChord class.
* A chord is part or whole of the curve of a circle, but with the start point and end point connected by a line segment.
*
* @author CookieMaker
*
* @version $Revision: 1.00 $
*/
public class JFChord extends AbstractArc{
/**
* A XML string tag represents an Chord
*/
public static final String XML_CHORD ="Chord";
/**
* initialization for JFChord
*/
private void initChord(){
setObjectType(ShapeConst.SHAPETYPE_CHORD);
setXMLTag(XML_CHORD);
m_arc.setArcType(Arc.CHORD);
}
/**
* Constructor for JFChord
*/
public JFChord(){
initChord();
}
/**
* Constructor for JFChord
*/
public JFChord(AbstractArc arc){
setArc(arc);
initChord();
}
/**
* Constructor for JFChord
* @param x1,y1 start point of this chord
* @param x2,y2 end point of this chord
*/
public JFChord(double x1,double y1, double x2, double y2){
initChord();
addNode(x1,y1);
addNode(x2,y2);
finishDrawing();
}
/**
* Constructor for JFChord
* @param centerx,centery center point of this chord
* @param x1,y1 start point of this chord
* @param angle Angle of this chord.
*/
public JFChord(double centerx, double centery,double x1,double y1, double angle){
initChord();
m_arc.setValue(new JFPoint(centerx,centery),new JFPoint(x1,y1),angle);
finishDrawing();
}
/**
* Draw an arc on canvas, by specified line format.
*
* @param g A graphic canvas.
* @param isXorMode If is in xor mode now.
*
*/
public void drawArc(Graphics g, boolean isXorMode){
GeneralPath path =getArcPath();
path.closePath();
double zoom =getZoomScale();
if (!isXorMode){
Rect rect =getBounds();
rect.setValue(rect.getX() * zoom, rect.getY() * zoom, rect.getWidth() * zoom, rect.getHeight() * zoom);
m_fillFormat.draw(g,path,rect);
m_lineFormat.draw(g,path);
}else
((Graphics2D)g).draw(path);
}
/**
* Creates a new AbstractObject of the same class and with the same contents as this object.
* This method implements the method defined in AbstractObject.
*
* @return A clone of this class.
*
*/
protected AbstractObject cloneMe() throws CloneNotSupportedException{
return new JFChord();
}
/**
* Init all ports of this shape.
* An object will always has its one or more stable ports and some customized ports,
*/
protected void initPorts(){
if (m_portList.size()==0){
try{
JFPoint startPoint =m_arc.getStartPoint();
JFPoint endPoint =m_arc.getEndPoint();
JFPoint controlPoint =m_arc.getControlPoint();
m_portList.addPort(new ArcPort(this,Port.PORTTYPE_DEFAULT,controlPoint,0.5,JFArcPoint.POINTTYPE_CURVE));
m_portList.addPort(new ArcPort(this,Port.PORTTYPE_DEFAULT,startPoint.midPoint(endPoint),0.5,JFArcPoint.POINTTYPE_CHORD));
}catch(Exception e){
}
}
m_portList.setZoomScale(getZoomScale());
}
/**
* Get the arrow format of current object.
*
* @return The arrow format.
*
*/
public Arrow getArrow(){
return null;
}
/**
* Set the arrow format of current object.
*
* @param arrow A new arrow format object.
*
*/
public void setArrow(Arrow arrow){
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -