View Javadoc
1 /* ------------------------------------------------------------------- 2 GeoVISTA Center (Penn State, Dept. of Geography) 3 Java source file for the class LayerShape 4 Copyright (c), 2002, GeoVISTA Center 5 Original Author: Frank Hardisty 6 $Author: hardisty $ 7 $Id: LayerShape.java,v 1.7 2003/07/14 16:37:16 hardisty Exp $ 8 $Date: 2003/07/14 16:37:16 $ 9 This library is free software; you can redistribute it and/or 10 modify it under the terms of the GNU Lesser General Public 11 License as published by the Free Software Foundation; either 12 version 2.1 of the License, or (at your option) any later version. 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 You should have received a copy of the GNU Lesser General Public 18 License along with this library; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 ------------------------------------------------------------------- */ 21 22 package edu.psu.geovista.app.map; 23 24 //import edu.psu.geovista.data.geog.DataSetForApps; 25 26 import java.awt.*; 27 import java.awt.event.*; 28 import java.awt.geom.*; 29 import java.awt.image.*; 30 31 import java.net.*; 32 33 import java.util.*; 34 35 import javax.swing.*; 36 import javax.swing.event.*; 37 38 import edu.psu.geovista.ui.Fisheyes; 39 40 /*** 41 * Layer and its subclasses are responsible for rendering spatial data, 42 * using classifications and symbolizations set by the user. 43 * 44 * The spatial data to be rendered is expected to be in user device space. 45 */ 46 public abstract class LayerShape { 47 public static String COMMAND_SELECTION = "cmdSel"; 48 private static int STATUS_NOT_SELECTED = 0; //default 49 private static int STATUS_SELECTED = 1; 50 public static final int LAYER_TYPE_POINT = 0; 51 public static final int LAYER_TYPE_LINE = 1; 52 public static final int LAYER_TYPE_POLYGON = 2; 53 public static final int LAYER_TYPE_RASTER = 3; 54 public static final int LAYER_TYPE_SYMBOL = 4; 55 public static final int FILL_ORDER_MAX = 3; 56 private transient Rectangle extent; 57 protected transient Shape[] spatialData; //in user space 58 protected transient Shape[] originalSpatialData; //originalCoordinates 59 private transient Rectangle[] boundingBoxes; 60 private transient int indication; 61 private transient AffineTransform xform; 62 private transient int[] classification; 63 private transient int[] focus; 64 protected transient int[] selectedObservations; 65 protected transient int[] selectedObservationsFullIndex; 66 protected transient int[] selectedObservationsOld; 67 protected transient int[] selectedObservationsOldFullIndex; 68 private transient Color[] objectColors; 69 private transient double[][] data; //column, row 70 private transient String[] variableNames; 71 private transient BufferedImage buff; 72 private transient int currOrderColumn; 73 private transient int currColorColumn; 74 private transient int[] conditionArray; 75 76 //Colors 77 //private Color colorSelection = new Color(Color.blue.getRed(),Color.blue.getGreen(),Color.blue.getBlue(),128); 78 private transient Color colorSelection = Color.blue; 79 private transient Color colorIndication = new Color(Color.green.getRed(), 80 Color.green.getGreen(), 81 Color.green.getBlue(), 150); 82 83 //private Color colorIndication = Color.green; 84 private transient Color colorNull = Color.darkGray; 85 private transient Color colorOutOfFocus = Color.black; 86 private transient Color colorNotInStudyArea = Color.black; 87 private transient Color colorLine = Color.black; 88 private transient Color colorAuxLine = Color.darkGray; 89 private transient Color colorBackground = Color.white; 90 private transient float defaultStrokeWidth; 91 private transient Stroke defaultStroke; 92 private transient Stroke selectionStroke; 93 private transient Stroke deselectionStroke; 94 private transient TexturePaint selectionTexture; 95 private transient TexturePaint indicationTexture; 96 private boolean isAuxiliary = false; 97 private transient float[] spatialDataArea; //area of spatial data in pixels 98 transient Fisheyes fisheyes; 99 transient boolean colorsRecieved = false; 100 transient boolean selectionExists = false; 101 transient boolean selOriginalColorMode = true; 102 103 public LayerShape() { 104 this.indication = Integer.MIN_VALUE; 105 this.selectedObservations = new int[0]; 106 this.xform = new AffineTransform(); 107 defaultStroke = new BasicStroke(1f); 108 selectionStroke = new BasicStroke(2f); 109 deselectionStroke = new BasicStroke(2f); 110 selectedObservationsOld = new int[0]; 111 makeTextures(); 112 } 113 114 private void makeTextures() { 115 int texSize = 4; 116 117 Rectangle2D.Float indRect = new Rectangle2D.Float(0, 0, texSize, texSize); 118 BufferedImage indBuff = new BufferedImage(texSize, texSize, 119 BufferedImage.TYPE_INT_ARGB); 120 Graphics2D indG2 = indBuff.createGraphics(); 121 indG2.setColor(this.colorIndication); 122 indG2.drawLine(0, texSize, texSize, 0); 123 this.indicationTexture = new TexturePaint(indBuff, indRect); 124 125 Rectangle2D.Float selRect = new Rectangle2D.Float(0, 0, texSize, texSize); 126 BufferedImage selBuff = new BufferedImage(texSize, texSize, 127 BufferedImage.TYPE_INT_ARGB); 128 Graphics2D selG2 = selBuff.createGraphics(); 129 if (this.selOriginalColorMode) { 130 selG2.setColor(this.colorBackground); 131 } 132 else { 133 selG2.setColor(this.colorSelection); 134 } 135 136 BasicStroke doubleWide = new BasicStroke(2f); 137 138 selG2.setStroke(doubleWide); 139 selG2.drawLine(0, 0, texSize, texSize); 140 //%%%%%%%%%%%%%%%%%%%% 141 //selG2.setColor(this.colorSelection); 142 //selG2.fill(new Rectangle(selBuff.getWidth(),selBuff.getHeight())); 143 //%%%%%%%%%%%%%%%%%%%%%% 144 this.selectionTexture = new TexturePaint(selBuff, selRect); 145 } 146 147 private void initColors() { 148 this.objectColors = new Color[spatialData.length]; 149 150 for (int i = 0; i < objectColors.length; i++) { 151 objectColors[i] = Color.yellow; 152 } 153 154 this.conditionArray = new int[spatialData.length]; 155 } 156 157 public Point findCentroid(int obs) { 158 159 Shape s = this.spatialData[obs]; 160 161 //here's an inaccurate but fast algorithm. To do: replace with something 162 //more accurate but also fast. 163 Rectangle rect = s.getBounds(); 164 int x = (int) (rect.getX() + rect.getWidth() / 2d); 165 int y = (int) (rect.getY() + rect.getHeight() / 2d); 166 Point p = new Point(x, y); 167 168 return p; 169 } 170 171 //begin accessors 172 public void setExtent(Rectangle extent) { 173 this.extent = extent; 174 } 175 176 //MapCanvas calls this on resize and data being set 177 public void setSpatialData(Shape[] spatialData) { 178 /* 179 //special stuff for Chaomei 180 if (this.isAuxiliary) { 181 //String[] observationNames = dataSet.getObservationNames(); 182 int[] numPoints = new int[25]; 183 int x = 0; 184 int y = 0; 185 int prevX = 0; 186 int prevY = 0; 187 int whichShape = 0; 188 int numSkipped = 0; 189 System.out.println(spatialData.length); 190 for (int i = 0; i < spatialData.length; i++) { 191 //System.out.println(i); 192 //special thing: if points are identical to previous points, we skip 'em 193 PathIterator pi = spatialData[i].getPathIterator(new AffineTransform()); 194 int numPolys = 0; 195 while (!pi.isDone()) { 196 float[] coords = new float[6]; 197 int segType = pi.currentSegment(coords); 198 x = (int)coords[0]; 199 y = (int)coords[1]; 200 if (segType == PathIterator.SEG_MOVETO) { 201 x = Integer.MAX_VALUE; 202 y = Integer.MAX_VALUE; 203 numPolys++; 204 numPoints[numPolys] = 0; 205 } 206 if (x == prevX && y == prevY) { 207 numSkipped++; 208 } else { 209 numPoints[numPolys]++; 210 prevX = x; 211 prevY = y; 212 } 213 pi.next(); 214 }//wend 215 pi = spatialData[i].getPathIterator(new AffineTransform()); 216 //System.out.println(observationNames[i]); 217 System.out.println(numPolys); 218 numPolys = 0; 219 while (!pi.isDone()) { 220 float[] coords = new float[6]; 221 int segType = pi.currentSegment(coords); 222 x = (int)coords[0]; 223 y = (int)coords[1]; 224 if (segType == PathIterator.SEG_MOVETO) { 225 x = Integer.MAX_VALUE; 226 y = Integer.MAX_VALUE; 227 numPolys++; 228 System.out.println(numPoints[numPolys]); 229 } 230 if (x == prevX && y == prevY) { 231 numSkipped++; 232 } else { 233 System.out.println(coords[0] +","+ coords[1]); 234 prevX = x; 235 prevY = y; 236 } 237 pi.next(); 238 }//wend 239 } //next spatialData 240 System.out.println("num skipped " + numSkipped); 241 } //end if aux 242 //end special stuff for chaomei*/ 243 this.spatialData = spatialData; 244 245 //we need to check for null if this is the first time through 246 //we need to check for length in case the spatial data 247 //has changed. 248 //however the spatial data might well change with no other changes 249 //needed, in case of panning or zooming, for instance. 250 int numObs = spatialData.length; 251 252 if ( (classification == null) || (classification.length != numObs)) { 253 classification = new int[spatialData.length]; 254 } 255 256 if ( (objectColors == null) || (this.objectColors.length != numObs)) { 257 this.initColors(); 258 } 259 260 if ( (selectedObservationsFullIndex == null) || 261 (selectedObservationsFullIndex.length != numObs)) { 262 selectedObservationsFullIndex = new int[spatialData.length]; 263 } 264 265 if ( (selectedObservationsOldFullIndex == null) || 266 (selectedObservationsOldFullIndex.length != numObs)) { 267 selectedObservationsOldFullIndex = new int[spatialData.length]; 268 } 269 270 if ( (conditionArray == null) || (conditionArray.length != numObs)) { 271 conditionArray = new int[numObs]; 272 } 273 274 if ( (spatialDataArea == null) || (spatialDataArea.length != numObs)) { 275 spatialDataArea = new float[numObs]; 276 } 277 } 278 279 public Shape[] getSpatialData() { 280 return this.spatialData; 281 } 282 283 public Color[] getColors() { 284 return this.objectColors; 285 } 286 287 public void setBoundingBoxes(Rectangle[] boundingBoxes) { 288 this.boundingBoxes = boundingBoxes; 289 } 290 291 public void setIndication(int indication) { 292 this.indication = indication; 293 } 294 295 public void setXform(AffineTransform xform) { 296 this.xform = xform; 297 } 298 299 public void setClassification(int[] classification) { 300 this.classification = classification; 301 } 302 303 public void setFocus(int[] focus) { 304 this.focus = focus; 305 } 306 307 //just sets data 308 public void setSelectedObservations(int[] selectedObservations) { 309 //copy old full index values 310 for (int i = 0; i < selectedObservationsFullIndex.length; i++) { 311 selectedObservationsOldFullIndex[i] = selectedObservationsFullIndex[i]; 312 } 313 314 //reset full index array 315 for (int i = 0; i < selectedObservationsFullIndex.length; i++) { 316 selectedObservationsFullIndex[i] = this.STATUS_NOT_SELECTED; 317 } 318 319 //set correct selection values in full index 320 for (int i = 0; i < selectedObservations.length; i++) { 321 int obs = selectedObservations[i]; 322 selectedObservationsFullIndex[obs] = this.STATUS_SELECTED; 323 } 324 //set selectionExists for rendering 325 if (selectedObservations.length > 0) { 326 this.selectionExists = true; 327 } 328 else { 329 this.selectionExists = false; 330 } 331 332 this.selectedObservations = selectedObservations; //this happens anyway 333 334 //copy current selection values to the old one. 335 if (selectedObservationsOld.length != selectedObservations.length) { 336 selectedObservationsOld = new int[selectedObservations.length]; 337 } 338 339 for (int i = 0; i < selectedObservations.length; i++) { 340 selectedObservationsOld[i] = selectedObservations[i]; 341 342 } 343 } 344 345 // //paints as well as sets data 346 // public void setSelectedObservations(int[] selectedObservations, Graphics2D g2) { 347 // //if (this.selectedObservations == selectedObservations) { 348 // // return; 349 // //} 350 // //copy old full index values 351 // for (int i = 0; i < selectedObservationsFullIndex.length; i++) { 352 // selectedObservationsOldFullIndex[i] = selectedObservationsFullIndex[i]; 353 // } 354 // 355 // //reset full index array 356 // for (int i = 0; i < selectedObservationsFullIndex.length; i++) { 357 // selectedObservationsFullIndex[i] = this.STATUS_NOT_SELECTED; 358 // } 359 // 360 // //set correct selection values in full index 361 // for (int i = 0; i < selectedObservations.length; i++) { 362 // int obs = selectedObservations[i]; 363 // selectedObservationsFullIndex[obs] = this.STATUS_SELECTED; 364 // } 365 // //set selectionExists for rendering 366 // if (selectedObservations.length > 0) { 367 // this.selectionExists = true; 368 // } 369 // else { 370 // this.selectionExists = false; 371 // } 372 // 373 // this.selectedObservations = selectedObservations; //this happens anyway 374 // 375 // //now we render. 376 // //step one: paint observations that were selected but now are not. 377 // for (int i = 0; i < selectedObservationsOld.length; i++) { 378 // int obs = selectedObservationsOld[i]; 379 // 380 // if (selectedObservationsFullIndex[obs] != this.STATUS_SELECTED) { 381 // this.renderObservationNoIndication(obs, g2); 382 // } //end if 383 // } //next obs 384 // 385 // //step two: paint observations that are selected 386 // for (int i = 0; i < selectedObservations.length; i++) { 387 // int obs = selectedObservations[i]; 388 // 389 // //if (selectedObservationsOldFullIndex[obs] != this.STATUS_SELECTED) { 390 // this.renderObservationNoIndication(obs, g2); 391 // 392 // //}//end if 393 // } //next obs 394 // 395 // //copy current selection values to the old one. 396 // if (selectedObservationsOld.length != selectedObservations.length) { 397 // selectedObservationsOld = new int[selectedObservations.length]; 398 // } 399 // 400 // for (int i = 0; i < selectedObservations.length; i++) { 401 // selectedObservationsOld[i] = selectedObservations[i]; 402 // } 403 // 404 // } 405 406 public int[] getSelectedObservations() { 407 return this.selectedObservations; 408 } 409 410 public void setIsAuxiliary(boolean isAuxiliary) { 411 this.isAuxiliary = isAuxiliary; 412 413 int red = Color.darkGray.getRed(); 414 int green = Color.darkGray.getGreen(); 415 int blue = Color.darkGray.getBlue(); 416 int alpha = 200; 417 Color transGray = new Color(red, green, blue, alpha); 418 this.colorLine = transGray; 419 this.defaultStroke = new BasicStroke(2f); 420 } 421 422 public void setParentSize(int height, int width) { 423 int shapeCount = 0; 424 Rectangle currBox = new Rectangle(0, 0, width, height); 425 426 for (int i = 0; i < this.spatialData.length; i++) { 427 if (currBox.intersects(spatialData[i].getBounds())) { 428 shapeCount++; 429 } 430 } 431 432 if (shapeCount <= 0) { 433 return; 434 } 435 436 this.spatialDataArea = new float[shapeCount]; 437 438 int counter = 0; 439 440 for (int i = 0; i < spatialData.length; i++) { 441 if (currBox.intersects(spatialData[i].getBounds2D())) { 442 Rectangle rect = spatialData[i].getBounds(); 443 444 float area = (float) spatialData[i].getBounds().getWidth() * 445 (float) spatialData[i].getBounds() 446 .getHeight(); 447 spatialDataArea[counter] = area; 448 449 //System.out.println("area = " + area); 450 counter++; 451 } 452 } 453 454 Arrays.sort(spatialDataArea); 455 456 int firstForth = spatialDataArea.length / 2; 457 float shapeArea = spatialDataArea[firstForth]; 458 459 //System.out.println("LayerShape.setParent, shapeCount = " + shapeCount); 460 //System.out.println(",shapeArea = " + shapeArea); 461 float strokeWidth = 0f; 462 463 if (shapeArea < 40) { 464 strokeWidth = 0f; 465 } 466 else if (shapeArea < 2500) { 467 strokeWidth = 0.1f; 468 } 469 else if (shapeArea < 5000) { 470 strokeWidth = 1f; 471 } 472 else if (shapeArea < 500000) { 473 strokeWidth = 2f; 474 } 475 else { 476 strokeWidth = 3f; 477 } 478 //if (strokeWidth > 3f) strokeWidth = 3f;//max size 479 //System.out.println("strokeWidth = " + strokeWidth); 480 //System.out.println(); 481 this.defaultStroke = new BasicStroke(strokeWidth); 482 483 //this.defaultStroke = new BasicStroke(strokeWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND); 484 this.defaultStrokeWidth = strokeWidth; 485 if (strokeWidth < 1) { //start with at least one for finding selectionStroke 486 strokeWidth = 1; 487 } 488 this.selectionStroke = new BasicStroke(strokeWidth * 1.5f, 489 BasicStroke.CAP_ROUND, 490 BasicStroke.JOIN_ROUND); 491 } 492 493 public void setOriginalSpatialData(Shape[] spatialData) { 494 this.originalSpatialData = spatialData; 495 } 496 497 public Shape[] getOriginalSpatialData() { 498 return this.originalSpatialData; 499 } 500 501 public boolean getIsAuxiliary() { 502 return this.isAuxiliary; 503 } 504 505 public void setObjectColors(Color[] objectColors) { 506 this.objectColors = objectColors; 507 this.colorsRecieved = true; 508 } 509 510 public void setData(double[][] data) { 511 this.data = data; 512 } 513 514 public void setVariableNames(String[] variableNames) { 515 this.variableNames = variableNames; 516 } 517 518 public void setCurrOrderColumn(int currOrderColumn) { 519 this.currOrderColumn = currOrderColumn; 520 } 521 522 public void setCurrColorColumn(int currColorColumn) { 523 this.currColorColumn = currColorColumn; 524 } 525 526 public void setColorSelection(Color colorSelection) { 527 this.colorSelection = colorSelection; 528 this.makeTextures(); 529 } 530 531 public void setColorIndication(Color colorIndication) { 532 this.colorIndication = colorIndication; 533 this.makeTextures(); 534 } 535 536 public void setColorNull(Color colorNull) { 537 this.colorNull = colorNull; 538 } 539 540 public void setColorOutOfFocus(Color colorOutOfFocus) { 541 this.colorOutOfFocus = colorOutOfFocus; 542 } 543 544 public void setColorNotInStudyArea(Color colorNotInStudyArea) { 545 this.colorNotInStudyArea = colorNotInStudyArea; 546 } 547 548 /*** 549 * put your documentation comment here 550 * @param conditionArray 551 */ 552 public void setConditionArray(int[] conditionArray) { 553 this.conditionArray = conditionArray; 554 } 555 556 /*** 557 * put your documentation comment here 558 * @param conditionArray 559 */ 560 public int[] getConditionArray() { 561 return this.conditionArray; 562 } 563 564 public void setSelOriginalColorMode(boolean selOriginalColorMode) { 565 this.selOriginalColorMode = selOriginalColorMode; 566 this.makeTextures(); 567 } 568 569 //end accessors 570 // Abstract methods that must be implemented by a subclass 571 public abstract void findSelection(int x1, int x2, int y1, int y2); 572 573 public abstract void findSelectionShift(int x1, int x2, int y1, int y2); 574 575 public abstract int findIndication(int x, int y); 576 577 /* 578 * SelectionX1 is expected to be less than selectionX2, same with Y1 and y2. 579 * Selected observations should be rendered with the color "colorSelection". 580 */ 581 public int[] findSelection(Rectangle2D selBox) { 582 //Rectangle selBox = new Rectangle(selectionX1,selectionY1,selectionX2-selectionX1,selectionY2-selectionY1); 583 584 Vector selObs = new Vector(); 585 for (int i = 0; i < this.spatialData.length; i++) { 586 Rectangle shpBox = this.spatialData[i].getBounds(); 587 Rectangle2D r2 = null; 588 if (selBox.intersects(shpBox)) { 589 if (this.spatialData[i].contains(selBox) || 590 this.spatialData[i].intersects(selBox)) { 591 selObs.add(new Integer(i)); 592 } //end if really intersects 593 } //end if rough intersects 594 } //next 595 int[] selObsInt = new int[selObs.size()]; 596 int j = 0; 597 for (Enumeration e = selObs.elements(); e.hasMoreElements(); ) { 598 Integer anInt = (Integer) e.nextElement(); 599 selObsInt[j] = anInt.intValue(); 600 j++; 601 } 602 return selObsInt; 603 } 604 605 public String toString() { 606 String s = this.getClass().toString(); 607 608 if (this.spatialData == null) { 609 s = s + ", spatialData == null."; 610 } 611 else { 612 s = s + ", spatialData.length = " + spatialData.length + "."; 613 } 614 615 return s; 616 } 617 618 public void renderObservation(int obs, Graphics2D g2) { 619 if (obs < 0) { 620 return; 621 } 622 Shape shp = spatialData[obs]; 623 if (fisheyes != null) { 624 shp = fisheyes.transform(shp); 625 } 626 if (conditionArray[obs] > -1) { 627 g2.setStroke(this.defaultStroke); 628 629 Color color = this.objectColors[obs]; 630 g2.setColor(color); 631 g2.fill(shp); 632 g2.setColor(Color.black); 633 g2.draw(shp); 634 if (this.selOriginalColorMode) { 635 if (this.selectedObservationsFullIndex[obs] == this.STATUS_NOT_SELECTED && 636 this.selectionExists) { 637 g2.setPaint(this.selectionTexture); 638 639 g2.fill(shp); 640 } 641 } 642 else if (!this.selOriginalColorMode) { 643 if (this.selectedObservationsFullIndex[obs] == this.STATUS_SELECTED) { 644 g2.setPaint(this.selectionTexture); 645 646 g2.fill(shp); 647 } 648 649 650 651 } 652 653 654 } //end if condition 655 656 if (obs == indication) { 657 Stroke tempStroke = g2.getStroke(); 658 g2.setStroke(this.selectionStroke); 659 g2.setColor(this.colorIndication); 660 g2.draw(shp); 661 if (fisheyes == null) { 662 g2.setStroke(tempStroke); 663 g2.setPaint(this.indicationTexture); 664 g2.fill(shp); 665 } 666 667 } 668 } 669 670 public void renderObservationNoIndication(int obs, Graphics2D g2) { 671 if (obs < 0) { 672 return; 673 } 674 if (this.objectColors.length <= obs) { 675 return; 676 } 677 Shape shp = spatialData[obs]; 678 if (fisheyes != null) { 679 shp = fisheyes.transform(shp); 680 } 681 682 if (conditionArray[obs] > -1) { 683 g2.setStroke(this.defaultStroke); 684 if(!this.selOriginalColorMode || this.selectedObservationsFullIndex[obs] == this.STATUS_SELECTED ||!this.selectionExists){ 685 Color color = this.objectColors[obs]; 686 g2.setColor(color); 687 g2.fill(shp); 688 } 689 690 if (this.defaultStrokeWidth >= 0.1f) { 691 g2.setColor(this.colorLine); 692 g2.draw(shp); 693 } 694 695 if (this.selOriginalColorMode) { 696 if (this.selectedObservationsFullIndex[obs] == this.STATUS_NOT_SELECTED && 697 this.selectionExists) { 698 g2.setPaint(this.selectionTexture); 699 700 //g2.fill(shp); 701 } 702 } 703 else if (!this.selOriginalColorMode) { 704 if (this.selectedObservationsFullIndex[obs] == this.STATUS_SELECTED) { 705 g2.setPaint(this.selectionTexture); 706 707 g2.fill(shp); 708 } 709 710 711 712 } 713 714 } //end if condition 715 //System.out.println("selOriginal = " + this.selOriginalColorMode); 716 } 717 718 private int paintTimes; 719 public void render(Graphics2D g2) { 720 721 if (this.objectColors == null) { 722 System.out.println("LayerShape, render called on null objectColors"); 723 return; 724 } 725 726 if (g2 == null) { 727 throw new IllegalArgumentException(this.toString() + 728 " Null graphics passed in to render(Graphics2D)."); 729 } 730 731 if (this.isAuxiliary) { 732 this.renderAux(g2); 733 734 return; 735 } 736 //Color c = this.objectColors[0]; 737 //System.out.println(paintTimes); 738 //paintTimes++; 739 // System.out.println("red = " + c.red); 740 // System.out.println("green = " + c.green); 741 // System.out.println("blue = " + c.blue); 742 // System.out.println("..."); 743 for (int path = 0; path < spatialData.length; path++) { 744 this.renderObservationNoIndication(path, g2); 745 } 746 } //end method 747 748 private void renderAux(Graphics2D g2) { 749 //draw all shapes 750 751 RenderingHints qualityHints = new RenderingHints(null); 752 753 qualityHints.put(RenderingHints.KEY_ANTIALIASING, 754 RenderingHints.VALUE_ANTIALIAS_ON); 755 756 qualityHints.put(RenderingHints.KEY_RENDERING, 757 RenderingHints.VALUE_RENDER_QUALITY); 758 759 g2.setRenderingHints(qualityHints); 760 //if (this.defaultStrokeWidth >= 0.1f) { 761 g2.setColor(this.colorAuxLine); 762 g2.setStroke(this.selectionStroke); 763 764 if (spatialData != null) { 765 int numPaths = spatialData.length; 766 767 for (int path = 0; path < numPaths; path++) { 768 Shape s = spatialData[path]; 769 if (fisheyes != null) { 770 s = fisheyes.transform(s); 771 } 772 g2.draw(s); 773 } // end for path 774 } // end if null 775 //} //end if stroke width > 1 776 } 777 778 public Color getColorBackground() { 779 return colorBackground; 780 } 781 782 public void setColorBackground(Color colorBackground) { 783 this.colorBackground = colorBackground; 784 int rgb = colorBackground.getRed() + colorBackground.getGreen() + colorBackground.getBlue(); 785 //System.out.println("rgb " + rgb); 786 if (rgb > 300){ 787 //its close to white, so 788 this.colorLine = Color.lightGray; 789 }else 790 this.colorLine = Color.darkGray; 791 this.makeTextures(); 792 } 793 }

This page was automatically generated by Maven