View Javadoc
1 package edu.psu.geovista.app.matrix; 2 3 /*** 4 * Title: MixedGraphMatrix 5 * Description: Manipulable Matrix 6 * Copyright: Copyright (c) 2001 7 * Company: GeoVISTA Center 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 java.awt.image.*; 16 import java.awt.geom.AffineTransform; 17 import javax.swing.event.*; 18 import javax.swing.*; 19 import java.io.*; 20 import edu.psu.geovista.symbolization.*; 21 import edu.psu.geovista.data.geog.DataSetForApps; 22 import edu.psu.geovista.app.scatterplot.*; 23 import edu.psu.geovista.ui.event.*; 24 25 public class FixedRowMatrix extends AbstractMatrix 26 implements ListSelectionListener{ 27 28 private static final int DEFAULT_NUM_GRAPHES = 4; 29 private transient int[] rowInitOrder; 30 private transient int[] columnInitOrder; 31 private transient int[] rowOrder; 32 private transient int[] columnOrder; 33 private String[] attributesArray; 34 private String[] observNames; 35 private int selectedObv; 36 protected transient EventListenerList listenerList = new EventListenerList(); 37 private SPTagButton[] columnButton; 38 private JComboBox attCombo; 39 private int yIdx=0; 40 private static ImageIcon leftRightArrow; 41 private static ImageIcon topDownArrow; 42 private static Insets nullInsets; 43 private Class[] elementClasses = new Class[DEFAULT_NUM_GRAPHES]; 44 private String[] elementClassNames = new String[DEFAULT_NUM_GRAPHES]; 45 private int graphTypeNumber; 46 private String[] varTags; 47 protected ImageIcon matrixIcon = new ImageIcon(this.getClass().getResource("resources/matrixicon16.gif")); 48 49 public FixedRowMatrix() { 50 super(); 51 this.setSize(panelWidthPixels, panelHeightPixels); 52 } 53 54 /*** 55 * put your documentation comment here 56 * @param classname 57 */ 58 public void setElementClassName0 (String classname) { 59 this.elementClassNames[0] = classname; 60 /*try { 61 setElementClass0((this.elementClassNames[0] != null) ? getClass().forName(this.elementClassNames[0]) : 62 null); 63 } catch (Exception e) { 64 e.printStackTrace(); 65 }*/ 66 } 67 68 public void setElementClassName1 (String classname) { 69 this.elementClassNames[1] = classname; 70 /*try { 71 setElementClass1((this.elementClassNames[1] != null) ? getClass().forName(this.elementClassNames[1]) : 72 null); 73 } catch (Exception e) { 74 e.printStackTrace(); 75 }*/ 76 } 77 78 public void setElementClassName2 (String classname) { 79 this.elementClassNames[2] = classname; 80 /*try { 81 setElementClass2((this.elementClassNames[2] != null) ? getClass().forName(this.elementClassNames[2]) : 82 null); 83 } catch (Exception e) { 84 e.printStackTrace(); 85 }*/ 86 } 87 88 public void setElementClassName3 (String classname) { 89 this.elementClassNames[3] = classname; 90 /*try { 91 setElementClass3((this.elementClassNames[3] != null) ? getClass().forName(this.elementClassNames[3]) : 92 null); 93 } catch (Exception e) { 94 e.printStackTrace(); 95 }*/ 96 } 97 /*** 98 * put your documentation comment here 99 * @return 100 */ 101 public String getElementClassName0 () { 102 return this.elementClassNames[0]; 103 } 104 105 public String getElementClassName1 () { 106 return this.elementClassNames[1]; 107 } 108 109 public String getElementClassName2 () { 110 return this.elementClassNames[2]; 111 } 112 113 public String getElementClassName3 () { 114 return this.elementClassNames[3]; 115 } 116 117 /*** 118 * put your documentation comment here 119 * @param obj 120 */ 121 public void setElementClass0 (Object obj) { 122 setElementClassName0((obj != null) ? obj.getClass().getName() : null); 123 } 124 125 public void setElementClass1 (Object obj) { 126 setElementClassName1((obj != null) ? obj.getClass().getName() : null); 127 } 128 129 public void setElementClass2 (Object obj) { 130 setElementClassName2((obj != null) ? obj.getClass().getName() : null); 131 } 132 133 public void setElementClass3 (Object obj) { 134 setElementClassName3((obj != null) ? obj.getClass().getName() : null); 135 } 136 /*** 137 * put your documentation comment here 138 * @param clazz 139 */ 140 /* public void setElementClass0 (Class clazz) { 141 this.elementClasses[0] = clazz; 142 } 143 144 public void setElementClass1 (Class clazz) { 145 this.elementClasses[1] = clazz; 146 } 147 public void setElementClass2 (Class clazz) { 148 this.elementClasses[2] = clazz; 149 } 150 151 public void setElementClass3 (Class clazz) { 152 this.elementClasses[3] = clazz; 153 } 154 */ 155 156 /*** 157 * Overwrite the method in AbstractMatrix, because the size of the matrix is different. 158 * @param condition 159 */ 160 public void setConditionArray (int[] condition) { 161 if (condition.equals(null)){ 162 return; 163 } else { 164 this.conditionArray = condition; 165 for (int k = 0; k < plotNumber*this.graphTypeNumber; k++) { 166 MatrixElement otherElement = element[k]; 167 if (otherElement != null){ 168 otherElement.setConditionArray(conditionArray); 169 } 170 } 171 repaint(); 172 } 173 } 174 175 public void setSelectedObvs(int[] selected) { 176 //System.out.println("Set Selected Obs: "); 177 if(selected == null){ 178 return; 179 }else{ 180 for(int i = 0; i < this.selectedObvsInt.length; i++){ 181 this.selectedObvsInt[i] = 0; 182 } 183 for(int i = 0; i < selected.length; i++){ 184 this.selectedObvsInt[selected[i]] = 1; 185 } 186 } 187 this.multipleSelectionColors = null; 188 //Once selection from other components has been set, pass it to each element inside of matrix. 189 for (int k = 0; k < plotNumber*this.graphTypeNumber; k++) { 190 MatrixElement otherElement = element[k]; 191 otherElement.setSelections(this.selectedObvsInt); 192 otherElement.setMultipleSelectionColors(this. 193 multipleSelectionColors); 194 } 195 repaint(); 196 } 197 198 protected synchronized void init () { 199 //System.out.println("get in init()..."); 200 if (!this.recreate) { 201 return; // maybe display error message. 202 } 203 this.removeAll(); 204 graphTypeNumber = 0; 205 attList = new JList(this.attributesDisplay); 206 attCombo = new JComboBox(this.attributesDisplay); 207 for (int i = 0; i < DEFAULT_NUM_GRAPHES; i ++){ 208 if (this.elementClassNames[i] != null){ 209 try {this.elementClasses[graphTypeNumber] = getClass().forName(this.elementClassNames[i]); 210 } catch (Exception e) { 211 e.printStackTrace(); 212 } 213 graphTypeNumber ++; 214 } 215 } 216 varTags = new String[plotNumber]; 217 if (this.dataObject != null) { 218 this.element = new MatrixElement[plotNumber*graphTypeNumber]; 219 matrixLayout = new GridBagLayout(); 220 c = new SPGridBagConstraints(); 221 c.fill = GridBagConstraints.BOTH; 222 this.createMatrix(); 223 Container parent = getParent(); 224 if (parent != null) { 225 parent.validate(); 226 } 227 else { 228 validate(); 229 } 230 } 231 super.registerIndicationListeners(); 232 } 233 234 //Set up elements in matrix. 235 protected void createMatrix () { 236 //System.out.println("create SP:"); 237 this.setLayout(matrixLayout); 238 Dimension size = getSize(); 239 Dimension plotSize = new Dimension(size.width/plotNumber, size.height/graphTypeNumber); 240 columnButton = new SPTagButton[plotNumber]; 241 SPTagButton[] rowButton = new SPTagButton[this.graphTypeNumber]; 242 Dimension tagDm = new Dimension(0, 0); 243 configButton = new JButton(); 244 try { 245 for (int i = 0; i < graphTypeNumber + 1; i++) { 246 for (int j = 0; j < plotNumber + 1; j++) { 247 if ((i == 0) && (j == 0)) { 248 c.weightx = 0.0; 249 c.weighty = 0.0; 250 c.gridwidth = 1; 251 c.gridheight = 1; 252 configButton.setIcon(this.matrixIcon); 253 configButton.setMargin(this.nullInsets); 254 configButton.addActionListener(new java.awt.event.ActionListener() { 255 256 /*** 257 * Set up the attributes for plotted in SPM. 258 * @param e 259 */ 260 public void actionPerformed (ActionEvent e) { 261 try { 262 configButton_actionPerformed(e); 263 } catch (Exception exception) {} 264 } 265 }); 266 c.column = j; 267 c.row = i; 268 matrixLayout.setConstraints(configButton, c); 269 add(configButton); 270 } 271 else if ((i == 0) && (j != 0)) { 272 c.weightx = 1.0; 273 c.weighty = 0.0; 274 c.gridwidth = this.DEFAULT_BUTTON_CONSTRAINTS; 275 c.gridheight = 1; 276 if (j == plotNumber) 277 c.gridwidth = GridBagConstraints.REMAINDER; //end row 278 varTags[j-1] = this.attributesDisplay[plottedAttributes[j - 1]]; 279 columnButton[j-1] = new SPTagButton(varTags[j-1]); 280 columnButton[j-1].setMargin(this.nullInsets); 281 columnButton[j-1].addMouseListener(columnButton[j-1]); 282 columnButton[j-1].addMouseMotionListener(columnButton[j-1]); 283 c.column = j; 284 c.row = i; 285 matrixLayout.setConstraints(columnButton[j-1], c); 286 add(columnButton[j-1]); 287 288 } 289 else if ((i != 0) && (j == 0)) { 290 c.weightx = 0.0; 291 c.weighty = 1.0; 292 c.gridwidth = 1; 293 c.gridheight = this.DEFAULT_BUTTON_CONSTRAINTS; 294 String yVarTag = this.attributesDisplay[yIdx]; 295 rowButton[i-1] = new SPTagButton("s"); 296 rowButton[i-1].setMargin(this.nullInsets); 297 rowButton[i-1].setVerticalAlignment(SwingConstants.BOTTOM); 298 //JLabel rowLabel = new JLabel(); 299 AffineTransform trans = new AffineTransform(); 300 trans.rotate(-Math.PI/2); 301 Font font = new Font("", Font.BOLD, 11); 302 font = font.deriveFont(trans); 303 //rowLabel.setFont(font); 304 //BufferedImage labelImage = new BufferedImage(rowLabel.getWidth()+1,rowLabel.getHeight()+1,BufferedImage.TYPE_INT_ARGB); 305 //Graphics2D g2 = labelImage.createGraphics(); 306 //rowButton[i-1].paint(g2); 307 rowButton[i-1].setFont(font); 308 rowButton[i-1].setText(yVarTag); 309 rowButton[i-1].addMouseListener(rowButton[i-1]); 310 rowButton[i-1].addMouseMotionListener(rowButton[i-1]); 311 c.column = j; 312 c.row = i; 313 matrixLayout.setConstraints(rowButton[i-1], c); 314 add(rowButton[i-1]); 315 } 316 else { 317 c.weightx = 1.0; 318 c.weighty = 1.0; 319 c.gridwidth = this.DEFAULT_BUTTON_CONSTRAINTS; 320 c.gridheight = this.DEFAULT_BUTTON_CONSTRAINTS; 321 if (j == plotNumber) 322 c.gridwidth = GridBagConstraints.REMAINDER; //end row 323 int indexCurrent = (i - 1)*(plotNumber) + (j - 1); 324 int[] dataIndices = new int[2]; 325 dataIndices[0] = plottedAttributes[j - 1] + 1; 326 dataIndices[1] = yIdx+1; 327 //construct of each element 328 this.element[indexCurrent] = (MatrixElement)this.elementClasses[i - 1].newInstance(); 329 this.element[indexCurrent].setAxisOn(false); 330 this.element[indexCurrent].setDataObject(this.dataObject); 331 this.element[indexCurrent].setSelectionColor(this.selectionColor); 332 this.element[indexCurrent].setBackground(background); 333 this.element[indexCurrent].setElementPosition(dataIndices); 334 if (this.bivarColorClasser != null){ 335 this.element[indexCurrent].setBivarColorClasser(this.bivarColorClasser, false); 336 } 337 c.column = j; 338 c.row = i; 339 matrixLayout.setConstraints((Component)this.element[indexCurrent], c); 340 int w = matrixLayout.getConstraints((Component)this.element[indexCurrent]).gridwidth; 341 add((Component)this.element[indexCurrent]); 342 if (rowButton[i-1].getText() == "s"){ 343 rowButton[i-1].setText(this.stringToVertical(this.element[indexCurrent].getShortDiscription())); 344 } 345 this.element[indexCurrent].addActionListener(new ActionListener() { 346 347 /*** 348 * Get the event from a unit plot and send it to all units. 349 * @param e 350 */ 351 public void actionPerformed (ActionEvent e) { 352 // This gets the source or originator of the event 353 try { 354 unit_actionPerformed(e); 355 } catch (Exception exception) {} 356 } 357 }); 358 } 359 } 360 } 361 } catch (Exception e) { 362 e.printStackTrace(); 363 } 364 for (int j = 0; j < plotNumber; j++) { 365 if (columnButton[j].getPreferredSize().getWidth() > tagDm.getWidth()) 366 tagDm = columnButton[j].getPreferredSize(); 367 //System.out.println("tagDm: " + tagDm.getWidth() + tagDm.getHeight()); 368 } 369 for (int j = 0; j < plotNumber; j++) { 370 columnButton[j].setPreferredSize(tagDm); 371 columnButton[j].setMinimumSize(tagDm); 372 columnButton[j].setMaximumSize(tagDm); 373 } 374 Dimension rowTag = new Dimension((int)tagDm.getHeight(), (int)tagDm.getHeight()); 375 configButton.setPreferredSize(rowTag); 376 configButton.setMinimumSize(rowTag); 377 configButton.setMaximumSize(rowTag); 378 } 379 380 /*** 381 * put your documentation comment here 382 * @param e 383 */ 384 private void unit_actionPerformed (ActionEvent e) { 385 //System.out.println("action performed..."); 386 MatrixElement source = (MatrixElement)e.getSource(); 387 String command = e.getActionCommand(); 388 if (command.compareTo(MatrixElement.COMMAND_POINT_SELECTED) == 0) { 389 //System.out.println("SPMC.plotUnitPanel.actionPerformed(), point selected"); 390 //selectedObvs = source.getSelectedObservations(); 391 this.selectedObvsInt = source.getSelections(); 392 for (int k = 0; k < plotNumber*graphTypeNumber; k++) { 393 MatrixElement otherElement = element[k]; 394 // Don't recall the scatterplot which generated the original event 395 if (otherElement != source) { 396 //otherElement.setSelectedObservations(selectedObvs); 397 otherElement.setSelections(this.selectedObvsInt); 398 } 399 } 400 this.repaint(); 401 fireChangeEvent(); 402 this.fireSelectionChanged(this.getSelectedObvs()); 403 }else if (command.compareTo(MatrixElement.COMMAND_COLOR_CLASSFICIATION) == 0) { 404 this.bivarColorClasser = source.getBivarColorClasser(); 405 for (int k = 0; k < plotNumber*graphTypeNumber; k++) { 406 MatrixElement otherElement = element[k]; 407 // Don't recall the scatterplot which generated the original event 408 if (otherElement != source) { 409 otherElement.setBivarColorClasser(this.bivarColorClasser, false); 410 } 411 } 412 this.repaint(); 413 //fireChangeEvent(); 414 } else if (command.compareTo(MatrixElement.COMMAND_DATARANGE_SET) == 0) { 415 //System.out.println("in axis reset..."); 416 double[] xAxisExtents = source.getXAxisExtents(); 417 double[] yAxisExtents = source.getYAxisExtents(); 418 int pos = 0; 419 for (int k = 0; k < this.graphTypeNumber*plotNumber; k++) { 420 MatrixElement otherElement = element[k]; 421 // Don't recall the scatterplot which generated the original event 422 if (otherElement == source) { 423 pos = k; 424 break; 425 } 426 } 427 int r = pos/plotNumber; 428 int c = pos%plotNumber; 429 430 for (int i = 0; i < this.plotNumber; i++) { 431 element[r + i].setYAxisExtents(yAxisExtents); 432 //element[r + i].repaint(); 433 //System.out.println("in y axis reset..."); 434 } 435 for (int i = 0; i < this.graphTypeNumber; i++) { 436 if (element[c + i*plotNumber].getClass().getName() == "edu.psu.geovista.app.scatterplot.ScatterPlot"){ 437 element[c + i*plotNumber].setXAxisExtents(xAxisExtents); 438 } 439 } 440 } else { 441 System.err.println("Unknown command! = " + command); 442 } 443 } 444 445 /*** 446 * Shift columns or rows in the matrix. 447 * @param lastPos 448 * @param newPos 449 */ 450 private void moveColumn (int lastPos, int newPos) { 451 int indicesRow; 452 int indicesCol; 453 int[] indicesLast1; 454 int[] indicesNew1; 455 int[] indicesLast2; 456 int[] indicesNew2; 457 String varTagMoved = new String(varTags[lastPos - 1]); 458 varTags[lastPos - 1] = varTags[newPos - 1]; 459 this.columnButton[lastPos - 1].setText(varTags[lastPos - 1]); 460 varTags[newPos - 1] = varTagMoved; 461 this.columnButton[newPos - 1].setText(varTags[newPos - 1]); 462 //System.out.println("lastPos: " + lastPos + "newPos:" + newPos); 463 for (int i = 0; i < this.graphTypeNumber; i++) { 464 indicesLast1 = (element[i*plotNumber + lastPos - 1].getElementPosition()); 465 //indicesLast2 = (element[(lastPos - 1)*plotNumber + i].getElementPosition()); 466 indicesRow = indicesLast1[0]; 467 //indicesCol = indicesLast2[1]; 468 indicesNew1 = element[i*plotNumber + newPos - 1].getElementPosition(); 469 //indicesNew2 = element[(newPos - 1)*plotNumber + i].getElementPosition(); 470 indicesLast1[0] = indicesNew1[0]; 471 //indicesLast2[1] = indicesNew2[1]; 472 element[i*plotNumber + lastPos - 1].setElementPosition(indicesLast1); 473 //element[(lastPos - 1)*plotNumber + i].setElementPosition(indicesLast2); 474 indicesNew1[0] = indicesRow; 475 //indicesNew2[1] = indicesCol; 476 element[i*plotNumber + newPos - 1].setElementPosition(indicesNew1); 477 //element[(newPos - 1)*plotNumber + i].setElementPosition(indicesNew2); 478 } 479 } 480 481 /*** 482 * Configure attributes for plotted in matrix. 483 * @param e 484 */ 485 private void configButton_actionPerformed (ActionEvent e) { 486 attSelectDialog(400, 400); 487 } 488 489 JFrame dummyFrame = new JFrame(); 490 JDialog dialog = null; 491 JScrollPane dialogPane = null; 492 493 /*** 494 * put your documentation comment here 495 * @param x 496 * @param y 497 */ 498 private void attSelectDialog (int x, int y) { 499 attList.setSelectedIndices(this.plottedAttributes); 500 if (this.dialog == null) { 501 this.dialog = new JDialog(dummyFrame, "Attributes for Plot", true); 502 JButton selectButton; 503 JButton closeButton; 504 dialog.setSize(200, 300); 505 dialog.getContentPane().setLayout(new BorderLayout()); 506 attList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 507 //attList.addListSelectionListener(this); 508 //JScrollPane scrollPane = new JScrollPane(attList); 509 this.dialogPane = new JScrollPane(attList); 510 511 attCombo.setSelectedIndex(yIdx); 512 attCombo.addActionListener(new ActionListener() { 513 public void actionPerformed(ActionEvent e) { 514 JComboBox cb = (JComboBox)e.getSource(); 515 yIdx = cb.getSelectedIndex(); 516 } 517 }); 518 JPanel comboPanel = new JPanel(new BorderLayout()); 519 comboPanel.add(attCombo, BorderLayout.NORTH); 520 521 selectButton = new JButton("Apply"); 522 selectButton.addActionListener(new java.awt.event.ActionListener() { 523 524 /*** 525 * put your documentation comment here 526 * @param e 527 */ 528 public void actionPerformed (ActionEvent e) { 529 selectButton_actionPerformed(e); 530 } 531 }); 532 closeButton = new JButton("Close"); 533 closeButton.addActionListener(new java.awt.event.ActionListener() { 534 535 /*** 536 * put your documentation comment here 537 * @param e 538 */ 539 public void actionPerformed (ActionEvent e) { 540 closeButton_actionPerformed(e); 541 } 542 }); 543 544 JPanel buttonPanel = new JPanel(new BorderLayout()); 545 buttonPanel.add(selectButton, BorderLayout.WEST); 546 buttonPanel.add(closeButton, BorderLayout.EAST); 547 JPanel namePanel = new JPanel(new GridLayout(1,2)); 548 namePanel.add(new JLabel("Column Vars:")); 549 namePanel.add(new JLabel("Row Var:")); 550 JPanel attPanel = new JPanel(new GridLayout(1,2)); 551 attPanel.add(this.dialogPane); 552 attPanel.add(comboPanel); 553 dialog.getContentPane().add(namePanel, BorderLayout.NORTH); 554 dialog.getContentPane().add(attPanel, BorderLayout.CENTER); 555 dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH); 556 } 557 else { 558 this.dialogPane.setViewportView(attList); 559 } 560 this.attList.addListSelectionListener(this); 561 this.plottedAttributes = attList.getSelectedIndices(); 562 this.dialog.setLocation(x, y); 563 this.dialog.show(); 564 } 565 566 /*** 567 * put your documentation comment here 568 * @param e 569 */ 570 private void selectButton_actionPerformed (ActionEvent e) { 571 plotNumber = plottedAttributes.length; 572 init(); 573 } 574 575 /*** 576 * put your documentation comment here 577 * @param e 578 */ 579 private void closeButton_actionPerformed (ActionEvent e) { 580 dialog.hide(); 581 } 582 583 protected class SPTagButton extends JButton 584 implements MouseListener, MouseMotionListener { 585 586 /*** 587 * put your documentation comment here 588 * @param String label 589 */ 590 SPTagButton (String label) { 591 super(label); 592 //buttonLabel = label; 593 } 594 595 /*** 596 * put your documentation comment here 597 * @param ImageIcon icon 598 */ 599 SPTagButton (ImageIcon icon) { 600 super(icon); 601 } 602 603 /*** 604 * put your documentation comment here 605 * @param e 606 */ 607 public void mousePressed (MouseEvent e) { 608 JButton button = (JButton)e.getSource(); 609 SPGridBagConstraints gbconst = (SPGridBagConstraints)matrixLayout.getConstraints(button); 610 posLast = new Point(gbconst.column, gbconst.row); 611 posDrag = (Point)posLast.clone(); 612 } 613 614 /*** 615 * put your documentation comment here 616 * @param e 617 */ 618 public void mouseReleased (MouseEvent e) { 619 posNew = SwingUtilities.convertPoint((SPTagButton)e.getSource(), e.getX(), 620 e.getY(), FixedRowMatrix.this); 621 posNew = matrixLayout.location(posNew.x, posNew.y); 622 if (posNew.x > 4*(plotNumber - 1)) 623 posNew.setLocation(posNew.x/4 + 1, posNew.y/4); 624 else 625 posNew.setLocation(posNew.x/4, posNew.y/4); 626 //System.out.println("PosNewX: " + posNew.x + "posNewY: " + posNew.y); 627 int lastPos = 0; 628 int newPos = 0; 629 if (!validCellPos(posDrag) || !validCellPos(posNew)) 630 return; 631 if ((posDrag.x != posNew.x) && (posDrag.y == 0)) { 632 lastPos = posLast.x; 633 newPos = posNew.x; 634 moveColumn(lastPos, newPos); 635 posDrag = posNew; 636 repaint(); 637 } 638 /*else if (posDrag.y != posNew.y) { 639 lastPos = posLast.y; 640 newPos = posNew.y; 641 } 642 if (lastPos != newPos) { 643 moveRowAndColumn(lastPos, newPos); 644 posDrag = posNew; 645 repaint(); 646 }*/ 647 } 648 649 /*** 650 * put your documentation comment here 651 * @param e 652 */ 653 public void mouseExited (MouseEvent e) { 654 ; 655 } 656 657 /*** 658 * put your documentation comment here 659 * @param e 660 */ 661 public void mouseDragged (MouseEvent e) { 662 posNew = SwingUtilities.convertPoint((SPTagButton)e.getSource(), e.getX(), 663 e.getY(), FixedRowMatrix.this); 664 posNew = matrixLayout.location(posNew.x, posNew.y); 665 //System.out.println("PosNew0X: " + posNew.x + "posNew0Y: " + posNew.y); 666 if (posNew.x > 4*(plotNumber - 1)) 667 posNew.setLocation(posNew.x/4 + 1, posNew.y/4); 668 else 669 posNew.setLocation(posNew.x/4, posNew.y/4); 670 //System.out.println("PosNewX: " + posNew.x + "posNewY: " + posNew.y); 671 int lastPos = 0; 672 int newPos = 0; 673 if (!validCellPos(posDrag) || !validCellPos(posNew)) 674 return; 675 if (posDrag.x != posNew.x) { 676 lastPos = posDrag.x; 677 newPos = posNew.x; 678 moveColumn(lastPos, newPos); 679 posDrag = posNew; 680 repaint(); 681 } 682 /*else if (posDrag.y != posNew.y) { 683 lastPos = posDrag.y; 684 newPos = posNew.y; 685 } 686 if (lastPos != newPos) { 687 moveRowAndColumn(lastPos, newPos); 688 posDrag = posNew; 689 repaint(); 690 }*/ 691 } 692 693 /*** 694 * put your documentation comment here 695 * @param e 696 */ 697 public void mouseMoved (MouseEvent e) { 698 ; 699 } 700 701 /*** 702 * put your documentation comment here 703 * @param e 704 */ 705 public void mouseEntered (MouseEvent e) { 706 ; 707 } 708 709 /*** 710 * put your documentation comment here 711 * @param e 712 */ 713 public void mouseClicked (MouseEvent e) { 714 ; 715 } 716 } 717 718 /*** 719 * put your documentation comment here 720 * @param e 721 */ 722 public void valueChanged (ListSelectionEvent e) { 723 if (e.getValueIsAdjusting()) 724 return; 725 JList theList = (JList)e.getSource(); 726 if (theList.isSelectionEmpty()) { 727 return; 728 } 729 else { 730 plottedAttributes = theList.getSelectedIndices(); 731 } 732 } 733 734 private String stringToVertical (String s){ 735 String vSt; 736 char[] sChar = s.toCharArray(); 737 int len = sChar.length; 738 vSt = "<html> "; 739 for (int i = 0; i < len; i++){ 740 vSt = vSt + sChar[i] + "<br>"; 741 } 742 vSt = vSt + "</html> "; 743 return vSt; 744 } 745 746 }

This page was automatically generated by Maven