⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 triangle2d.java

📁 JGraph扩展应用。自定义Renderer,自定义视图View实现自定义工作流控件
💻 JAVA
字号:
/*
JOpenChart Java Charting Library and Toolkit
Copyright (C) 2001  Sebastian M焞ler
http://jopenchart.sourceforge.net

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Triangle2D.java
Created on 11. September 2002, 22:01
*/

package flow.graph.gui.graph.item;

import java.awt.geom.RectangularShape;
import java.awt.geom.Rectangle2D;
import java.awt.geom.PathIterator;
import java.awt.geom.AffineTransform;

/**
* This class implements a triangular shape.
* @author  smueller
*/
public class Triangle2D extends RectangularShape {

	protected double x = 0.0;

	protected double y = 0.0;

	protected double width = 0.0;

	protected double height = 0.0;

	protected boolean upsidedown = false;

	/** Creates a new instance of Triangle2D */
	public Triangle2D(double x, double y, double width, double height, boolean upsidedown) {
		setFrame(x, y, width, height);
		this.upsidedown = upsidedown;
	}

	public boolean contains(double param, double param1) {
		return false;
	}

	public boolean contains(double param, double param1, double param2, double param3) {
		return false;
	}

	public boolean intersects(double x, double y, double w, double h) {
		return false;
	}

	public Rectangle2D getBounds2D() {
		return new Rectangle2D.Double(x, y, width, height);
	}

	public double getHeight() {
		return height;
	}

	public PathIterator getPathIterator(final AffineTransform at) {
		return new PathIterator() {
			int state = 0;
			int maxstate = 4;
        
			double[][] dcurrentSegment = {{x + width/2, y},
									  {x, y + height},
									  {x + width, y + height},
									  {0.0, 0.0} };

        
			double[][] ddowncurrentSegment = {{x, y},
                                          {x + width/2, y + height},
                                          {x + width, y},
                                          {0.0, 0.0} };
                                      
			int[] segment = { PathIterator.SEG_MOVETO, PathIterator.SEG_LINETO, PathIterator.SEG_LINETO, PathIterator.SEG_CLOSE};
		
			public int currentSegment(double[] coords) { 
				if(!upsidedown) {
					coords[0] = dcurrentSegment[state][0];  
					coords[1] = dcurrentSegment[state][1];
				} else {
					coords[0] = ddowncurrentSegment[state][0];  
					coords[1] = ddowncurrentSegment[state][1];
				}
				if (at != null) {
				    at.transform(coords, 0, coords, 0, 1);
				}
				return segment[state];
			}
		
			public int currentSegment(float[] coords){ 
				if(!upsidedown) {
					coords[0] = (float)dcurrentSegment[state][0];  
					coords[1] = (float)dcurrentSegment[state][1];
				} else {
					coords[0] = (float)ddowncurrentSegment[state][0];  
					coords[1] = (float)ddowncurrentSegment[state][1];
				}
				if (at != null) {
				    at.transform(coords, 0, coords, 0, 1);
				}
				return segment[state];
			} 
		
			public int getWindingRule() { return PathIterator.WIND_NON_ZERO; }
			public boolean isDone() { return (state == maxstate); } 
			public void next() { state++ ; } 
		};
	}

	public double getWidth() {
		return width;
	}

	public double getX() {
		return x;
	}

	public double getY() {
		return y;
	}

	public boolean isEmpty() {
		return (width<= 0.0 || height <= 0.0);
	}

	public void setFrame(double x, double y, double width, double height) {
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -