View Javadoc
1 /* ------------------------------------------------------------------- 2 GeoVISTA Center (Penn State, Dept. of Geography) 3 Java source file for the class LayerText 4 Copyright (c), 2002, GeoVISTA Center 5 All Rights Reserved. 6 Original Author: Frank Hardisty 7 $Author: hardisty $ 8 $Id: LayerText.java,v 1.2 2003/04/25 17:23:47 hardisty Exp $ 9 $Date: 2003/04/25 17:23:47 $ 10 Reference: Document no: 11 ___ ___ 12 ------------------------------------------------------------------- * 13 */ 14 15 16 package edu.psu.geovista.app.map; 17 18 //imports for Main method 19 import javax.swing.JFrame; 20 //other import statements 21 import java.util.*; 22 import java.awt.*; 23 import java.awt.geom.*; 24 25 26 /*** 27 * put your documentation comment here 28 */ 29 public class LayerText extends LayerShape { 30 transient Vector strings; 31 transient Vector points; 32 transient Vector fonts; 33 transient Vector colors; 34 transient Color defaultColor; 35 transient Font defaultFont; 36 //GeoReference gvGeoReference; 37 private transient boolean scalable; 38 39 40 public int findIndication(int x, int y) {return Integer.MIN_VALUE;} 41 /*** 42 * put your documentation comment here 43 * @param scalable 44 */ 45 public void setScaleable (boolean scalable) { 46 this.scalable = scalable; 47 } 48 49 /*** 50 * put your documentation comment here 51 * @return 52 */ 53 public boolean getScaleable () { 54 return this.scalable; 55 } 56 57 /*** 58 * put your documentation comment here 59 * @param s 60 * @param p 61 * @param f 62 * @param c 63 */ 64 public void addString (String s, Point p, Font f, Color c) { 65 strings.add(s); 66 points.add(p); 67 fonts.add(f); 68 colors.add(c); 69 } 70 71 /*** 72 * put your documentation comment here 73 * @param s 74 * @param p 75 * @param fontSize 76 * @param c 77 */ 78 public void addString (String s, Point p, float fontSize, Color c) { 79 strings.add(s); 80 points.add(p); 81 fonts.add(defaultFont.deriveFont(fontSize)); 82 colors.add(c); 83 } 84 85 /*** 86 * put your documentation comment here 87 * @param s 88 * @param p 89 */ 90 public void addString (String s, Point p) { 91 strings.add(s); 92 points.add(p); 93 fonts.add(defaultFont); 94 colors.add(defaultColor); 95 } 96 97 /*** 98 * put your documentation comment here 99 * @return 100 */ 101 public Vector getStrings () { 102 return strings; 103 } 104 105 /*** 106 * put your documentation comment here 107 * @return 108 */ 109 public Vector getPoints () { 110 return points; 111 } 112 113 /*** 114 * put your documentation comment here 115 * @return 116 */ 117 public Vector getFonts () { 118 return fonts; 119 } 120 121 122 123 124 /* 125 * selectionX1 is expected to be less than selectionX2, same with Y1 and y2 126 */ 127 public void findSelection (int selectionX1, int selectionX2, int selectionY1, 128 int selectionY2) { 129 130 } 131 /* 132 * selectionX1 is expected to be less than selectionX2, same with Y1 and y2 133 */ 134 public void findSelectionShift (int selectionX1, int selectionX2, int selectionY1, 135 int selectionY2) { 136 137 } 138 139 140 /*** 141 * put your documentation comment here 142 * @param g2 143 */ 144 public void render (Graphics2D g2) { 145 //test if text is in map or ui space 146 if (scalable == false) { 147 //AffineTransform tx = gvGeoReference.getUiAffineTransform(); 148 149 } 150 else { 151 //AffineTransform tx = gvGeoReference.getUiAffineTransform(); 152 153 } 154 int numStrings = strings.size(); 155 for (int stringNum = 0; stringNum < numStrings; stringNum++) { 156 Point p = (Point)getPoints().get(stringNum); 157 String drawS = (String)getStrings().get(stringNum); 158 Font f = (Font)getFonts().get(stringNum); 159 g2.setFont(f); 160 //Color c = (Color)getColors().get(stringNum); 161 //g2.setColor(c); 162 g2.drawString(drawS, p.x, p.y); 163 } 164 } 165 166 /*** 167 * dummy method to fit superclass 168 * @param polygonColors 169 */ 170 public void setColorIndex (int[] polygonColors) { 171 //this.colorIndex = polygonColors; 172 } 173 /*** 174 * dummy method to fit superclass 175 * @param polygonColors 176 */ 177 public int[] getColorIndex () { 178 //return this.colorIndex; 179 return null; 180 } 181 /*** 182 * Main method for testing. 183 */ 184 public static void main (String[] args) { 185 JFrame jFrame = new JFrame(); 186 jFrame.setSize(200, 200); 187 jFrame.show(); 188 Graphics2D g2 = (Graphics2D)jFrame.getGraphics(); 189 String s = "Hello World!"; 190 Point point = new Point(50, 100); 191 LayerText gvTextLayer = new LayerText(); 192 gvTextLayer.addString(s, point); 193 gvTextLayer.render(g2); 194 } 195 } 196 197 198

This page was automatically generated by Maven