View Javadoc
1 package edu.psu.geovista.app.matrix; 2 3 /*** 4 * <p>Title: </p> 5 * <p>Description: </p> 6 * <p>Copyright: Copyright (c) 2001</p> 7 * <p>Company: GeoVISTA Center</p> 8 * @author Xiping Dai 9 * @version 1.0 10 */ 11 import java.awt.*; 12 import java.lang.*; 13 import java.util.*; 14 import java.awt.event.*; 15 import javax.swing.event.*; 16 import javax.swing.*; 17 import java.io.*; 18 import java.net.URL; 19 import java.awt.geom.AffineTransform; 20 import edu.psu.geovista.symbolization.*; 21 import edu.psu.geovista.ui.event.*; 22 import edu.psu.geovista.classification.*; 23 24 public abstract class AbstractMatrix 25 extends JPanel 26 implements MouseListener, MouseMotionListener, ChangeListener, 27 ListSelectionListener, 28 SelectionListener, DataSetListener, ConditioningListener, 29 ColorArrayListener, IndicationListener, SubspaceListener, Serializable, 30 ColorClassifierListener { 31 32 protected static final int DEFAULT_MAX_NUM_ARRAYS = 3; 33 protected static final int DEFAULT_PANEL_HEIGHT_PIXELS = 300; 34 protected static final int DEFAULT_PANEL_WIDTH_PIXELS = 300; 35 protected static final int DEFAULT_BUTTON_CONSTRAINTS = 4; 36 protected transient Class elementClass; 37 protected transient Object[] dataObject; 38 protected transient int[] conditionArray = null; 39 protected transient String[] attributesDisplay; 40 protected transient String[] attributeDescriptions; 41 protected transient int plottedBegin = 0; 42 protected transient int plotNumber; 43 protected transient int maxNumArrays = DEFAULT_MAX_NUM_ARRAYS; 44 protected transient int[] plottedAttributes; 45 //protected transient Vector selectedObvs = new Vector(); 46 protected transient Color[] multipleSelectionColors; 47 protected transient Color[] colorArrayForObs; 48 protected transient MatrixElement[] element; 49 protected transient int[] selectedObvsInt; 50 protected transient int[] selections;//short array, sharing with other components 51 protected transient BivariateColorSymbolClassification bivarColorClasser; 52 protected transient Color selectionColor = Color.blue; 53 protected transient Color background = Color.white; 54 protected transient boolean selOriginalColorMode = true; 55 protected transient GridBagLayout matrixLayout; 56 protected transient Point posLast = new Point(); 57 protected transient Point posNew = new Point(); 58 protected transient Point posDrag = new Point(); 59 protected transient boolean recreate = true; 60 protected transient int panelWidthPixels = DEFAULT_PANEL_WIDTH_PIXELS; 61 protected transient int panelHeightPixels = DEFAULT_PANEL_HEIGHT_PIXELS; 62 protected transient JList attList; 63 protected transient JList descriptionList; 64 protected transient SPGridBagConstraints c; 65 protected static ImageIcon leftRightArrow; 66 protected static ImageIcon topDownArrow; 67 protected static Insets nullInsets; 68 private transient Vector indicListeners; 69 protected String[] varTags; 70 protected SPTagButton[] columnButton; 71 protected SPTagButton[] rowButton; 72 protected JButton configButton; 73 protected abstract void createMatrix(); 74 75 public AbstractMatrix() { 76 this.setPreferredSize(new Dimension(300, 300)); 77 } 78 79 /*** 80 * Set up the default size of matrix panel. 81 * @param widthPixels 82 * @param heightPixels 83 */ 84 public void setPanelSize(int widthPixels, int heightPixels) { 85 setSize(widthPixels, heightPixels); 86 //setPreferredSize(new Dimension(widthPixels, heightPixels)); 87 this.setMinimumSize(new Dimension(widthPixels, heightPixels)); 88 super.setLayout(null); 89 } 90 91 /*** 92 * put your documentation comment here 93 * @return 94 */ 95 public Class getElementClass() { 96 return this.elementClass; 97 } 98 99 /*** 100 * Data setup and matrix initialize. 101 * @param data 102 */ 103 public void setDataObject(Object[] data) { 104 if (data == null) { 105 return; 106 } 107 edu.psu.geovista.data.geog.DataSetForApps dataObjTransfer = new edu.psu. 108 geovista.data.geog.DataSetForApps(); 109 dataObjTransfer.setDataObject(data); 110 this.dataObject = dataObjTransfer.getDataSetNumericAndSpatial(); 111 this.conditionArray = dataObjTransfer.getConditionArray(); 112 this.attributesDisplay = dataObjTransfer.getAttributeNamesNumeric(); 113 if (dataObjTransfer.getAttributeDescriptions() != null){ 114 this.attributeDescriptions = dataObjTransfer.getAttributeDescriptions(); 115 } else{ 116 this.attributeDescriptions = null; 117 } 118 int numLen; 119 numLen = dataObjTransfer.getNumberNumericAttributes(); 120 //check if there are enough attributes to display in matrix from specified beginning. 121 if (plottedBegin >= numLen) { 122 System.err.println("There aren't enough attributes to display! Please reset the begin display attribute or reload a more attribute data file."); 123 return; 124 } 125 plotNumber = (numLen <= maxNumArrays) ? numLen : maxNumArrays; 126 if ( (plottedBegin + plotNumber) > numLen) { 127 plotNumber = numLen - plottedBegin; 128 } 129 this.plottedAttributes = new int[plotNumber]; 130 for (int i = plottedBegin; i < plottedBegin + plotNumber; i++) { 131 plottedAttributes[i - plottedBegin] = i; 132 } 133 //if (!selectedObvs.isEmpty()) { 134 // selectedObvs.clear(); 135 //} 136 int numObvs; 137 numObvs = dataObjTransfer.getNumObservations(); 138 this.selectedObvsInt = new int[numObvs]; 139 init(); 140 //registerIndicationListeners(); 141 } 142 143 protected void registerIndicationListeners() { 144 //register "this" with each element 145 for (int k = 0; k < element.length; k++) { 146 MatrixElement otherElement = element[k]; 147 otherElement.addIndicationListener(this); 148 } 149 //register all added indication listeners 150 if (this.indicListeners == null) { 151 return; 152 } 153 Vector listeners = this.indicListeners; 154 for (Enumeration e = listeners.elements(); e.hasMoreElements(); ) { 155 IndicationListener listener = (IndicationListener) e.nextElement(); 156 for (int k = 0; k < element.length; k++) { 157 MatrixElement otherElement = element[k]; 158 otherElement.addIndicationListener(listener); 159 } 160 } 161 162 } 163 164 public void setSelectedObvs(int[] selected) { 165 //System.out.println("Set Selected Obs: "); 166 if(selected == null){ 167 return; 168 }else{ 169 for(int i = 0; i < this.selectedObvsInt.length; i++){ 170 this.selectedObvsInt[i] = 0; 171 } 172 for(int i = 0; i < selected.length; i++){ 173 this.selectedObvsInt[selected[i]] = 1; 174 } 175 } 176 this.multipleSelectionColors = null; 177 //Once selection from other components has been set, pass it to each element inside of matrix. 178 for (int k = 0; k < this.element.length; k++) { 179 MatrixElement otherElement = element[k]; 180 otherElement.setSelections(this.selectedObvsInt); 181 otherElement.setMultipleSelectionColors(this. 182 multipleSelectionColors); 183 } 184 repaint(); 185 } 186 187 /*** 188 * Return index array for selected observations. 189 * @return 190 */ 191 public int[] getSelectedObvs() { 192 Vector selectedObvs = new Vector(); 193 for(int i = 0; i < this.selectedObvsInt.length; i ++){ 194 if (this.selectedObvsInt[i] == 1){ 195 selectedObvs.add(new Integer(i)); 196 } 197 } 198 selections = new int[selectedObvs.size()]; 199 for (int i = 0; i < selectedObvs.size(); i++) { 200 selections[i] = ( (Integer) selectedObvs.get(i)).intValue(); 201 } 202 return selections; 203 } 204 205 private void setIndicatedObv(int indicated) { 206 if (this.dataObject == null) { 207 return; 208 } 209 //Once selection from other components has been set, pass it to each element inside of matrix. 210 for (int k = 0; k < this.element.length; k++) { 211 // if (this.plotNumber * this.plotNumber != this.element.length){ 212 // return; 213 // } 214 MatrixElement otherElement = element[k]; 215 if (otherElement == null){ 216 return; 217 } 218 otherElement.setIndication(indicated); 219 } 220 } 221 222 /*** 223 * Set the maximum number of columns and rows can be shown in matrix. 224 * @param maxNum 225 */ 226 public void setMaxNumArrays(int maxNum) { 227 this.maxNumArrays = maxNum; 228 } 229 230 /*** 231 * Get the maximum number of columns and rows can be shown in matrix. 232 * @return 233 */ 234 public int getMaxNumArrays() { 235 return maxNumArrays; 236 } 237 238 /*** 239 * Set the beginning varaible. 240 * @param plottedBegin 241 */ 242 public void setPlottedBegin(int plottedBegin) { 243 this.plottedBegin = plottedBegin; 244 } 245 246 /*** 247 * Get the beginning varaible. 248 * @return 249 */ 250 public int getPlottedBegin() { 251 return plottedBegin; 252 } 253 254 /*** 255 * Set the attribute arrays which need to display in matrix by indices. 256 * @param plottedAtt 257 */ 258 public void setPlottedAttributes(int[] plottedAtt) { 259 this.plottedAttributes = plottedAtt; 260 } 261 262 /*** 263 * put your documentation comment here 264 * @param condition 265 */ 266 public void setConditionArray(int[] condition) { 267 268 if (condition.equals(null)) { 269 return; 270 } 271 else { 272 this.conditionArray = condition; 273 for (int k = 0; k < plotNumber * plotNumber; k++) { 274 MatrixElement otherElement = element[k]; 275 if (otherElement != null) { 276 otherElement.setConditionArray(conditionArray); 277 } 278 } 279 repaint(); 280 } 281 } 282 283 /*** 284 * Set up classification color for each matrix element. 285 * @param c 286 */ 287 public void setBivarColorClasser(BivariateColorSymbolClassification 288 bivarColorClasser) { 289 if (this != null) { 290 //return; 291 } 292 this.bivarColorClasser = bivarColorClasser; 293 if (this.bivarColorClasser == null) { 294 return; 295 } 296 int row, column; 297 boolean reverseColor = false; 298 for (int k = 0; k < this.element.length; k++) { 299 MatrixElement otherElement = element[k]; 300 String className = otherElement.getClass().getName(); 301 302 if (className != "edu.psu.geovista.app.scatterplot.ScatterPlot") { 303 row =k/this.plotNumber; 304 column = k%this.plotNumber; 305 if (row > column){ 306 reverseColor = true; 307 }else{ 308 reverseColor = false; 309 } 310 otherElement.setBivarColorClasser(this.bivarColorClasser, reverseColor); 311 } 312 } 313 } 314 315 public BivariateColorSymbolClassification getBivarColorClasser() { 316 return this.bivarColorClasser; 317 } 318 319 /*** 320 * Set up selection color for each matrix element. See in bean proporty. 321 * @param c 322 */ 323 public void setSelectionColor(Color c) { 324 this.selectionColor = c; 325 for (int k = 0; k < this.element.length; k++) { 326 MatrixElement otherElement = element[k]; 327 otherElement.setSelectionColor(this.selectionColor); 328 } 329 } 330 331 public void setColorArrayForObs(Color[] colorArray) { 332 if (this.element == null){ 333 return; 334 } 335 this.colorArrayForObs = colorArray; 336 for (int k = 0; k < this.element.length; k++) { 337 MatrixElement otherElement = element[k]; 338 otherElement.setColorArrayForObs(this.colorArrayForObs); 339 } 340 repaint(); 341 } 342 343 /*** 344 * put your documentation comment here 345 * @return 346 */ 347 public Color getSelectionColor() { 348 return this.selectionColor; 349 } 350 351 public boolean getSelOriginalColorMode() { 352 return selOriginalColorMode; 353 } 354 355 public void setSelOriginalColorMode(boolean selOriginalColorMode) { 356 this.selOriginalColorMode = selOriginalColorMode; 357 for (int k = 0; k < this.element.length; k++) { 358 MatrixElement otherElement = element[k]; 359 otherElement.setSelOriginalColorMode(this.selOriginalColorMode); 360 } 361 } 362 /*** 363 * Set up selection. Input is integer array, but internally use vector. 364 * @param 365 */ 366 public void setMultipleSelectionColors(Color[] multipleSelectionColors) { 367 //System.out.println("Set Selected colors: "); 368 this.multipleSelectionColors = multipleSelectionColors; 369 for(int i = 0; i < this.selectedObvsInt.length; i ++){ 370 this.selectedObvsInt[i] = 0; 371 } 372 for (int k = 0; k < plotNumber * plotNumber; k++) { 373 MatrixElement otherElement = element[k]; 374 otherElement.setSelections(this.selectedObvsInt); 375 otherElement.setMultipleSelectionColors(this. 376 multipleSelectionColors); 377 } 378 repaint(); 379 } 380 381 /*** 382 * Set up background color. See it in bean proporty. 383 * @param c 384 */ 385 public void setBackground(Color c) { 386 if (c == null) { 387 return; 388 } 389 background = c; 390 for (int k = 0; k < plotNumber * plotNumber; k++) { 391 MatrixElement otherElement = element[k]; 392 otherElement.setBackground(this.background); 393 } 394 } 395 396 /*** 397 * put your documentation comment here 398 * @return 399 */ 400 public Color getBackground() { 401 return background; 402 } 403 404 //Costomization of GridBagConstraints. We want to trace the position of rows and column for 405 //the function of row and column reposition. 406 protected class SPGridBagConstraints 407 extends GridBagConstraints { 408 protected int column; 409 protected int row; 410 } 411 412 public class SPTagButton 413 extends JButton 414 implements MouseListener, MouseMotionListener { 415 416 //String buttonLabel; 417 /*** 418 * put your documentation comment here 419 * @param String label 420 */ 421 SPTagButton(String label) { 422 super(label); 423 //buttonLabel = label; 424 } 425 426 /*** 427 * put your documentation comment here 428 * @param ImageIcon icon 429 */ 430 SPTagButton(ImageIcon icon) { 431 super(icon); 432 } 433 434 /*** 435 * put your documentation comment here 436 * @param e 437 */ 438 public void mousePressed(MouseEvent e) { 439 JButton button = (JButton) e.getSource(); 440 SPGridBagConstraints gbconst = (SPGridBagConstraints) matrixLayout. 441 getConstraints(button); 442 posLast = new Point(gbconst.column, gbconst.row); 443 posDrag = (Point) posLast.clone(); 444 } 445 446 /*** 447 * Mouse release event. Detect the destination of row or column reposition. 448 * @param e 449 */ 450 public void mouseReleased(MouseEvent e) { 451 posNew = SwingUtilities.convertPoint( (SPTagButton) e.getSource(), 452 e.getX(), 453 e.getY(), AbstractMatrix.this); 454 posNew = matrixLayout.location(posNew.x, posNew.y); 455 if (posNew.x > 4 * (plotNumber - 1)) { 456 posNew.setLocation(posNew.x / 4 + 1, posNew.y / 4); 457 } 458 else { 459 posNew.setLocation(posNew.x / 4, posNew.y / 4); 460 //System.out.println("PosNewX: " + posNew.x + "posNewY: " + posNew.y); 461 } 462 int lastPos = 0; 463 int newPos = 0; 464 if (!validCellPos(posDrag) || !validCellPos(posNew)) { 465 return; 466 } 467 if (posDrag.x != posNew.x) { 468 lastPos = posLast.x; 469 newPos = posNew.x; 470 } 471 else if (posDrag.y != posNew.y) { 472 lastPos = posLast.y; 473 newPos = posNew.y; 474 } 475 if (lastPos != newPos) { 476 moveRowAndColumn(lastPos, newPos); 477 posDrag = posNew; 478 repaint(); 479 } 480 } 481 482 /*** 483 * Mouse drag event. Detect the rows or columns on which row or column reposition passed. 484 * @param e 485 */ 486 public void mouseDragged(MouseEvent e) { 487 posNew = SwingUtilities.convertPoint( (SPTagButton) e.getSource(), 488 e.getX(), 489 e.getY(), AbstractMatrix.this); 490 posNew = matrixLayout.location(posNew.x, posNew.y); 491 //System.out.println("PosNew0X: " + posNew.x + "posNew0Y: " + posNew.y); 492 if (posNew.x > 4 * (plotNumber - 1)) { 493 posNew.setLocation(posNew.x / 4 + 1, posNew.y / 4); 494 } 495 else { 496 posNew.setLocation(posNew.x / 4, posNew.y / 4); 497 //System.out.println("PosNewX: " + posNew.x + "posNewY: " + posNew.y); 498 } 499 int lastPos = 0; 500 int newPos = 0; 501 if (!validCellPos(posDrag) || !validCellPos(posNew)) { 502 return; 503 } 504 if (posDrag.x != posNew.x) { 505 lastPos = posDrag.x; 506 newPos = posNew.x; 507 } 508 else if (posDrag.y != posNew.y) { 509 lastPos = posDrag.y; 510 newPos = posNew.y; 511 } 512 if (lastPos != newPos) { 513 moveRowAndColumn(lastPos, newPos); 514 posDrag = posNew; 515 repaint(); 516 } 517 } 518 519 /*** 520 * put your documentation comment here 521 * @param e 522 */ 523 public void mouseExited(MouseEvent e) { 524 ; 525 } 526 527 /*** 528 * put your documentation comment here 529 * @param e 530 */ 531 public void mouseMoved(MouseEvent e) { 532 ; 533 } 534 535 /*** 536 * put your documentation comment here 537 * @param e 538 */ 539 public void mouseEntered(MouseEvent e) { 540 ; 541 } 542 543 /*** 544 * put your documentation comment here 545 * @param e 546 */ 547 public void mouseClicked(MouseEvent e) { 548 ; 549 } 550 } 551 552 /*** 553 * put your documentation comment here 554 */ 555 protected void init() { 556 if (!this.recreate) { 557 return; // maybe display error message. 558 } 559 this.removeAll(); 560 setPanelSize(panelWidthPixels, panelHeightPixels); 561 562 if (this.dataObject != null) { 563 attList = new JList(this.attributesDisplay); 564 if (this.attributeDescriptions != null){ 565 descriptionList = new JList(this.attributeDescriptions); 566 } 567 this.element = new MatrixElement[plotNumber * plotNumber]; 568 matrixLayout = new GridBagLayout(); 569 c = new SPGridBagConstraints(); 570 //this.setLayout(matrixLayout); 571 c.fill = GridBagConstraints.BOTH; 572 varTags = new String[plotNumber]; 573 createMatrix(); 574 Container parent = getParent(); 575 if (parent != null) { 576 parent.validate(); 577 } 578 else { 579 validate(); 580 } 581 } 582 registerIndicationListeners(); 583 } 584 585 /*** 586 * put your documentation comment here 587 * @param pos 588 * @return 589 */ 590 protected boolean validCellPos(Point pos) { 591 return (pos.x == 0 && pos.y != 0) || (pos.x != 0 && pos.y == 0); 592 } 593 594 /*** 595 * Shift columns or rows in the matrix. 596 * @param lastPos 597 * @param newPos 598 */ 599 protected void moveRowAndColumn(int lastPos, int newPos) { 600 //System.out.println("move row or column..."); 601 int indicesRow; 602 int indicesCol; 603 int[] indicesLast1; 604 int[] indicesNew1; 605 int[] indicesLast2; 606 int[] indicesNew2; 607 String varTagMoved = new String(varTags[lastPos - 1]); 608 varTags[lastPos - 1] = varTags[newPos - 1]; 609 this.columnButton[lastPos - 1].setText(varTags[lastPos - 1]); 610 this.rowButton[lastPos - 1].setText(varTags[lastPos - 1]); 611 varTags[newPos - 1] = varTagMoved; 612 this.columnButton[newPos - 1].setText(varTags[newPos - 1]); 613 this.rowButton[newPos - 1].setText(varTags[newPos - 1]); 614 for (int i = 0; i < plotNumber; i++) { 615 indicesLast1 = (element[i * plotNumber + lastPos - 616 1].getElementPosition()); 617 indicesLast2 = (element[ (lastPos - 1) * plotNumber + 618 i].getElementPosition()); 619 //System.out.println("Indices before move" + indicesLast1[0] + indicesLast1[1]); 620 indicesRow = indicesLast1[0]; 621 indicesCol = indicesLast2[1]; 622 indicesNew1 = element[i * plotNumber + newPos - 623 1].getElementPosition(); 624 indicesNew2 = element[ (newPos - 1) * plotNumber + 625 i].getElementPosition(); 626 //System.out.println("Indices after move" + indicesNew1[0] + indicesNew1[1]); 627 indicesLast1[0] = indicesNew1[0]; 628 indicesLast2[1] = indicesNew2[1]; 629 element[i * plotNumber + lastPos - 630 1].setElementPosition(indicesLast1); 631 element[ (lastPos - 1) * plotNumber + 632 i].setElementPosition(indicesLast2); 633 indicesNew1[0] = indicesRow; 634 indicesNew2[1] = indicesCol; 635 element[i * plotNumber + newPos - 1].setElementPosition(indicesNew1); 636 element[ (newPos - 1) * plotNumber + 637 i].setElementPosition(indicesNew2); 638 639 /*this.remove((Component)this.element[i*plotNumber + lastPos - 1]); 640 this.add((Component)this.element[i*plotNumber + newPos - 1], i*plotNumber + lastPos - 1); 641 this.remove((Component)this.element[i*plotNumber + newPos - 1]); 642 this.add((Component)this.element[i*plotNumber + lastPos - 1], i*plotNumber + newPos - 1); 643 this.remove((Component)this.element[(lastPos - 1)*plotNumber + i]); 644 add((Component)this.element[(newPos - 1)*plotNumber + i], (lastPos - 1)*plotNumber + i); 645 this.remove((Component)this.element[(newPos - 1)*plotNumber + i]); 646 add((Component)this.element[(lastPos - 1)*plotNumber + i], (newPos - 1)*plotNumber + i); 647 this.revalidate(); 648 repaint();*/ 649 } 650 651 } 652 653 /*** 654 * put your documentation comment here 655 * @param e 656 */ 657 public void mousePressed(MouseEvent e) {} 658 659 /*** 660 * put your documentation comment here 661 * @param e 662 */ 663 public void mouseReleased(MouseEvent e) {} 664 665 /*** 666 * put your documentation comment here 667 * @param e 668 */ 669 public void mouseExited(MouseEvent e) { 670 ; 671 } 672 673 /*** 674 * put your documentation comment here 675 * @param e 676 */ 677 public void mouseDragged(MouseEvent e) {} 678 679 /*** 680 * put your documentation comment here 681 * @param e 682 */ 683 public void mouseMoved(MouseEvent e) { 684 ; 685 } 686 687 /*** 688 * put your documentation comment here 689 * @param e 690 */ 691 public void mouseEntered(MouseEvent e) { 692 ; 693 } 694 695 /*** 696 * put your documentation comment here 697 * @param e 698 */ 699 public void mouseClicked(MouseEvent e) { 700 ; 701 } 702 703 public void selectionChanged(SelectionEvent e) { 704 if (e.getMultipleSlectionColors() != null) { 705 this.setMultipleSelectionColors(e.getMultipleSlectionColors()); 706 } 707 else { 708 this.setSelectedObvs(e.getSelection()); 709 } 710 } 711 712 public void indicationChanged(IndicationEvent e) { 713 this.setIndicatedObv(e.getIndication()); 714 } 715 716 public void dataSetChanged(DataSetEvent e) { 717 this.setDataObject(e.getDataSet()); 718 } 719 720 public void conditioningChanged(ConditioningEvent e) { 721 this.setConditionArray(e.getConditioning()); 722 } 723 724 public void colorArrayChanged(ColorArrayEvent e) { 725 //System.out.println("colorArrayChanged..."); 726 this.setColorArrayForObs(e.getColors()); 727 } 728 729 public void colorClassifierChanged(ColorClassifierEvent e) { 730 if (e.getColorSymbolClassification() == null || this.dataObject == null) { 731 return; 732 } 733 boolean isX = false; 734 if (e.getOrientation() == e.SOURCE_ORIENTATION_X) { 735 isX = true; 736 } 737 if (this.bivarColorClasser == null){ 738 this.bivarColorClasser = new BivariateColorSymbolClassificationSimple(); 739 } 740 BivariateColorSymbolClassificationSimple biColor = ( 741 BivariateColorSymbolClassificationSimple)this.bivarColorClasser; 742 ColorSymbolClassificationSimple colorClasser = ( 743 ColorSymbolClassificationSimple) e.getColorSymbolClassification(); 744 ColorSymbolizer colorer = colorClasser.getColorer(); 745 Classifier classer = colorClasser.getClasser(); 746 747 if (isX) { 748 //System.out.println("setting x"); 749 biColor.setClasserX(classer); 750 biColor.setColorerX(colorer); 751 } 752 else { 753 //System.out.println("Setting Y"); 754 biColor.setClasserY(classer); 755 biColor.setColorerY(colorer); 756 } 757 // BivariateColorSymbolClassificationSimple biColor2 = new 758 // BivariateColorSymbolClassificationSimple(); 759 // ColorSymbolizer xSym = biColor.getColorerX(); 760 // ColorSymbolizer ySym = biColor.getColorerY(); 761 // biColor2.setColorerX(ySym); 762 // biColor2.setColorerY(xSym); 763 //this.bivarColorClasser = biColor; 764 if (this.bivarColorClasser == null) { 765 return; 766 } 767 768 int row, column; 769 boolean reverseColor = false; 770 for (int k = 0; k < this.element.length; k++) { 771 MatrixElement otherElement = element[k]; 772 String className = otherElement.getClass().getName(); 773 if (className != "edu.psu.geovista.app.scatterplot.ScatterPlot") { 774 //otherElement.setBivarColorClasser(biColor2); 775 row =k/this.plotNumber; 776 column = k%this.plotNumber; 777 if (row > column){ 778 reverseColor = true; 779 }else{ 780 reverseColor = false; 781 } 782 otherElement.setBivarColorClasser(this.bivarColorClasser, reverseColor); 783 } 784 else { 785 otherElement.setBivarColorClasser(this.bivarColorClasser, false); 786 } 787 } 788 789 } 790 791 public void subspaceChanged(SubspaceEvent e) { 792 int[] list = e.getSubspace(); 793 int maxVars = 8; 794 if (list.length > maxVars) { 795 list = new int[maxVars]; 796 for (int i = 0; i < maxVars; i++) { 797 list[i] = e.getSubspace()[i]; 798 } 799 } 800 plottedAttributes = list; 801 plotNumber = plottedAttributes.length; 802 this.init(); 803 } 804 805 /*** 806 * adds an IndicationListener to the elements 807 */ 808 public void addIndicationListener(IndicationListener l) { 809 if (this.indicListeners == null) { 810 this.indicListeners = new Vector(); 811 } 812 813 this.indicListeners.add(l); 814 if (element != null) { 815 for (int k = 0; k < element.length; k++) { 816 817 MatrixElement otherElement = element[k]; 818 otherElement.addIndicationListener(l); 819 } 820 821 } 822 } 823 824 /*** 825 * removes an IndicationListener from the elements 826 */ 827 public void removeIndicationListener(IndicationListener l) { 828 829 if (this.element == null){ 830 return; 831 } 832 for (int k = 0; k < this.element.length; k++) { 833 MatrixElement otherElement = element[k]; 834 otherElement.removeIndicationListener(l); 835 } 836 this.indicListeners.remove(l); 837 838 } 839 840 /*** 841 * adds an SelectionListener. 842 * @see EventListenerList 843 */ 844 public void addSelectionListener(SelectionListener l) { 845 listenerList.add(SelectionListener.class, l); 846 } 847 848 /*** 849 * removes an SelectionListener from the component. 850 * @see EventListenerList 851 */ 852 public void removeSelectionListener(SelectionListener l) { 853 listenerList.remove(SelectionListener.class, l); 854 855 } 856 857 /*** 858 * Notify all listeners that have registered interest for 859 * notification on this event type. The event instance 860 * is lazily created using the parameters passed into 861 * the fire method. 862 * @see EventListenerList 863 */ 864 protected void fireSelectionChanged(int[] newSelection) { 865 866 // Guaranteed to return a non-null array 867 Object[] listeners = listenerList.getListenerList(); 868 SelectionEvent e = null; 869 // Process the listeners last to first, notifying 870 // those that are interested in this event 871 for (int i = listeners.length - 2; i >= 0; i -= 2) { 872 if (listeners[i] == SelectionListener.class) { 873 // Lazily create the event: 874 if (e == null) { 875 e = new SelectionEvent(this, newSelection); 876 } 877 ( (SelectionListener) listeners[i + 1]).selectionChanged(e); 878 } 879 } //next i 880 881 } 882 883 /*** 884 * put your documentation comment here 885 * @param e 886 */ 887 public void stateChanged(ChangeEvent e) { 888 JButton button = (JButton) e.getSource(); 889 SPGridBagConstraints gbconst = (SPGridBagConstraints) matrixLayout. 890 getConstraints(button); 891 } 892 893 /*** 894 * put your documentation comment here 895 * @param l 896 */ 897 public void addChangeListener(ChangeListener l) { 898 this.listenerList.add(ChangeListener.class, l); 899 } 900 901 /*** 902 * put your documentation comment here 903 * @param l 904 */ 905 public void removeChangeListener(ChangeListener l) { 906 this.listenerList.remove(ChangeListener.class, l); 907 } 908 909 /*** 910 * put your documentation comment here 911 */ 912 protected void fireChangeEvent() { 913 Object[] listeners = this.listenerList.getListenerList(); 914 // Process the listeners last to first, notifying 915 // those that are interested in this event 916 for (int i = listeners.length - 2; i >= 0; i -= 2) { 917 if (listeners[i] == ChangeListener.class) { 918 ( (ChangeListener) listeners[i + 919 1]).stateChanged(new ChangeEvent(this)); 920 } 921 } // end for 922 } 923 924 /*** 925 * put your documentation comment here 926 * @param oos 927 * @exception IOException 928 */ 929 protected void writeObject(ObjectOutputStream oos) throws IOException { 930 oos.defaultWriteObject(); 931 } 932 933 /*** 934 * put your documentation comment here 935 * @param ois 936 * @exception ClassNotFoundException, IOException 937 */ 938 protected void readObject(ObjectInputStream ois) throws 939 ClassNotFoundException, 940 IOException { 941 ois.defaultReadObject(); 942 } 943 944 //Set up arrow figure for the first row and column buttons. 945 static { 946 try { 947 Class cl = UniPlotMatrix.class; 948 URL urlGifH = cl.getResource("arrow_h32.gif"); 949 URL urlGifV = cl.getResource("arrow_v32.gif"); 950 leftRightArrow = new ImageIcon(urlGifH); 951 topDownArrow = new ImageIcon(urlGifV); 952 // Just do this create once 953 nullInsets = new Insets(0, 0, 0, 0); 954 } 955 catch (Exception ex) { 956 ex.printStackTrace(); 957 } 958 } 959 960 /*** 961 * adds a SubspaceListener 962 */ 963 public void addSubspaceListener(SubspaceListener l) { 964 listenerList.add(SubspaceListener.class, l); 965 966 } 967 968 /*** 969 * removes an SubspaceListener from the component 970 */ 971 public void removeSubspaceListener(SubspaceListener l) { 972 listenerList.remove(SubspaceListener.class, l); 973 974 } 975 976 /*** 977 * Notify all listeners that have registered interest for 978 * notification on this event type. The event instance 979 * is lazily created using the parameters passed into 980 * the fire method. 981 * @see EventListenerList 982 */ 983 public void fireSubspaceChanged(int[] selection) { 984 // Guaranteed to return a non-null array 985 Object[] listeners = listenerList.getListenerList(); 986 SubspaceEvent e = null; 987 988 // Process the listeners last to first, notifying 989 // those that are interested in this event 990 for (int i = listeners.length - 2; i >= 0; i -= 2) { 991 if (listeners[i] == SubspaceListener.class) { 992 // Lazily create the event: 993 if (e == null) { 994 e = new SubspaceEvent(this, selection); 995 } 996 997 ( (SubspaceListener) listeners[i + 1]).subspaceChanged(e); 998 } 999 } //next i 1000 1001 } 1002 1003 }

This page was automatically generated by Maven