001 // GraphLab Project: http://graphlab.sharif.edu 002 // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology 003 // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ 004 package graphlab.graph.old; 005 006 import java.awt.*; 007 008 /** 009 * an arrow which is a0 polygon 010 */ 011 public class PolygonArrow implements Arrow { 012 /** 013 * 014 */ 015 private static final long serialVersionUID = -17351484519616222L; 016 private Polygon p; 017 private String name; 018 019 public PolygonArrow(Polygon p, String name) { 020 this.p = p; 021 this.name = name; 022 } 023 024 public String getName() { 025 return name; 026 } 027 028 public String toString() { 029 return name; 030 } 031 032 /** 033 * paints the arrow on the g which the size of (w,h), the w & h are disabled for this version 034 */ 035 public void paintArrow(Graphics g, int w, int h) { 036 // double sx=w/p.getBounds().getWidth(); 037 // double sy=h/p.getBounds().getHeight(); 038 039 Graphics2D gg = ((Graphics2D) g); 040 041 // gg.scale(sx, sy); 042 gg.fill(p); 043 // u should scale it back if scaled it 044 } 045 046 public Rectangle getBounds() { 047 return p.getBounds(); 048 } 049 }