All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.yaoqiang.graph.shape.AnnotationShape Maven / Gradle / Ivy

package org.yaoqiang.graph.shape;

import java.awt.Color;
import java.awt.Rectangle;

import com.mxgraph.canvas.mxGraphics2DCanvas;
import com.mxgraph.shape.mxBasicShape;
import com.mxgraph.util.mxPoint;
import com.mxgraph.view.mxCellState;

/**
 * PolylineShape
 * 
 * @author Shi Yaoqiang([email protected])
 */
public class AnnotationShape extends mxBasicShape {

	public void paintShape(mxGraphics2DCanvas canvas, mxCellState state) {
		Rectangle bounds = state.getRectangle();
		mxPoint p0, p1, p2, p3;
		double width = 20 * canvas.getScale();
		p0 = new mxPoint(bounds.getX() + width, bounds.getY());
		p1 = new mxPoint(bounds.getX(), bounds.getY());
		p2 = new mxPoint(bounds.getX(), bounds.getY() + bounds.getHeight());
		p3 = new mxPoint(bounds.getX() + width, bounds.getY() + bounds.getHeight());

		mxPoint[] points = new mxPoint[4];
		points[0] = p0;
		points[1] = p1;
		points[2] = p2;
		points[3] = p3;
		
		Color color = getStrokeColor(canvas, state);
		canvas.getGraphics().setColor(color);
		canvas.paintPolyline(points, false);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy