Revision 14821 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SymbolLevelsWindow.java

View differences:

SymbolLevelsWindow.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2 2
 *
3 3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4 4
 *
......
20 20
 *
21 21
 *  Generalitat Valenciana
22 22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
23
 *   Av. Blasco Ib��ez, 50
24 24
 *   46010 VALENCIA
25 25
 *   SPAIN
26 26
 *
......
117 117
	private JPanel pnlCenter = null;
118 118
	private JScrollPane srclLevels = null;
119 119
	private JTable tblLevels = null;
120
	private JButton btnUp = null; 
120
	private JButton btnUp = null;
121 121
	private JButton btnDown;
122 122
	private JPanel pnlSouth = null;
123 123
	private String[] advancedHeaders;
......
145 145
		wi.setHeight(getHeight());
146 146
		return wi;
147 147
	}
148
	
149 148
	/**
150 149
	 * Completes the main table of the panel with the symbols contained in the
151 150
	 * legend of the map.
......
232 231
		setModel(zSort);
233 232
		tblLevels.setRowHeight(23);
234 233
	}
235
	
236 234
	/**
237 235
	 * Sets the model
238 236
	 * @param plan ZSort
239 237
	 */
238

  
240 239
	public void setModel(ZSort plan) {
241 240
		advancedHeaders = new String[FIRST_LEVEL_COLUMN_INDEX
242 241
		                             +plan.getTopLevelIndexAllowed() ];
......
249 248
		initTableContents(getTblLevels(), plan, viewMode);
250 249
		getChkSpecifyDrawOrder().setSelected(plan.isUsingZSort());
251 250
	}
252
	
253 251
	/**
254 252
	 * Initializes the table that it is showed in the panel where the user can
255 253
	 * see the different symbols of the legend and has options to specify the
......
264 262
		Object[][] dataVector = null;
265 263
		ISymbol[] syms = zSort.getSymbols();
266 264
		String[] labels = zSort.getDescriptions();
267
		
265

  
268 266
		if (mode == DEFAULT_VIEW) {
269 267
			// default view (JOIN and MERGE)
270 268
			dataVector = new Object[syms.length][syms.length];
......
316 314
		} else {
317 315
			// advanced view (user may input the map level manually)
318 316
			dataVector = new Object[syms.length][
319
			                     FIRST_LEVEL_COLUMN_INDEX + /* this is the first column that 
317
			                     FIRST_LEVEL_COLUMN_INDEX + /* this is the first column that
320 318
			                     							 * contains a level for the symbol
321
			                     							 */ 
322
			                     								
319
			                     							 */
320

  
323 321
			                     zSort.getTopLevelIndexAllowed() + /* according to the set of
324 322
			                      									* symbols this will get the
325 323
			                      									* max level reachable
326
			                      									*/  
324
			                      									*/
327 325
			                     1 /* plus 1 to get a count instead of an index */];
328 326
			for (int i = 0; i < syms.length; i++) {
329 327
				dataVector[i][SYMBOL_COLUMN_INDEX] = syms[i];
......
341 339
			model.setDataVector(dataVector, advancedHeaders);
342 340
			table.setModel(model);
343 341
			for (int j = FIRST_LEVEL_COLUMN_INDEX; j < model.getColumnCount(); j++) {
344
				
342

  
345 343
				table.getColumnModel().getColumn(j).setCellRenderer(new NumberTableCellRenderer(true, false));
346 344
				table.getColumnModel().getColumn(j).setCellEditor(new IntegerTableCellEditor());
347 345
			}
......
393 391
		this.add(getPnlCenter(), BorderLayout.CENTER);
394 392
		this.add(getPnlSouth(), BorderLayout.SOUTH);
395 393
		tblLevels.addMouseListener(new MouseListener() {
396
			public void mouseReleased(MouseEvent e) { } 
394
			public void mouseReleased(MouseEvent e) { }
397 395
			public void mouseClicked(MouseEvent e)  { }
398 396
			public void mouseEntered(MouseEvent e)  { }
399
			public void mouseExited(MouseEvent e)  { 
397
			public void mouseExited(MouseEvent e)  {
400 398
				summary.sym = null;
401 399
				repaint();
402
			}
400
	}
403 401

  
404 402
			public void mousePressed(MouseEvent e) {
405 403
				Point where = e.getPoint();
......
409 407
				/*
410 408
				 * calculate the right border x-position of the symbol
411 409
				 * column
412
				 */
410
	 			*/
413 411
				int rightEdge = 0;
414 412
				for (int i = 0; i <= SYMBOL_COLUMN_INDEX; i++) {
415
					rightEdge += tblLevels.getColumnModel().getColumn(i).getWidth(); 
413
					rightEdge += tblLevels.getColumnModel().getColumn(i).getWidth();
416 414
				}
417
				if (whereX >= bounds.x && 
415
				if (whereX >= bounds.x &&
418 416
					whereX <= rightEdge + bounds.x &&
419 417
					whereY >= bounds.y &&
420 418
					whereY <= bounds.height + bounds.y) {
......
432 430
						summary.sym = null;
433 431
					}
434 432
					repaint();
435
				} 
433
				}
436 434
			}
437
			
435

  
438 436
		});
439 437

  
440 438
	}
......
448 446
		return chkSpecifyDrawOrder;
449 447
	}
450 448

  
451
	
449

  
452 450
	private JPanel getPnlCenter() {
453 451
		if (pnlCenter == null) {
454 452
			pnlCenter = new JPanel();
......
477 475
		return srclLevels;
478 476
	}
479 477

  
480
	
478

  
481 479
	private JTable getTblLevels() {
482 480
		if (tblLevels == null) {
483 481
			tblLevels = new JTable() {
......
487 485
				protected void paintComponent(Graphics g) {
488 486
					super.paintComponent(g);
489 487
					summary.paint((Graphics2D) g);
490
				}
488
		}
491 489
			};
492 490
			summary.rowHeight = tblLevels.getRowHeight();
493 491
		}
494 492
		return tblLevels;
495 493
	}
496 494

  
497
	
495

  
498 496
	private JButton getBtnUp() {
499 497
		if (btnUp == null) {
500
			btnUp = new JButton(new ImageIcon(getClass().
501
                    getClassLoader().getResource("images/up-arrow.png")));
498
			btnUp = new JButton(PluginServices.getIconTheme().get("arrow-up-icono"));
502 499
			btnUp.setActionCommand("MOVE_UP");
503 500
		}
504 501
		return btnUp;
505 502
	}
506
	
503

  
507 504
	private JButton getBtnDown() {
508 505
		if (btnDown == null) {
509
			btnDown = new JButton(new ImageIcon(getClass().
510
                    getClassLoader().getResource("images/down-arrow.png")));
506
			btnDown = new JButton(PluginServices.getIconTheme().get("arrow-down-icono"));
511 507
			btnDown.setActionCommand("MOVE_DOWN");
512 508
		}
513 509
		return btnDown;
514 510
	}
515 511

  
516
	
512

  
517 513
	private JPanel getPnlSouth() {
518 514
		if (pnlSouth == null) {
519 515
			pnlSouth = new JPanel(new BorderLayout());
......
529 525
		}
530 526
		return pnlSouth;
531 527
	}
532
	
528

  
533 529
	private JButton getBtnSwitchView() {
534 530
		if (btnSwitchView == null) {
535 531
			btnSwitchView = new JButton(
......
567 563
	private class SymbolSummary {
568 564
		int witdh;
569 565
		int rowHeight = 10;
570
		
566

  
571 567
		int rowIndex;
572
		
568

  
573 569
		IMultiLayerSymbol sym;
574
		
570

  
575 571
		void paint(Graphics2D g){
576
			
572

  
577 573
			if (sym != null) {
578 574
				int whereY = (rowHeight*(rowIndex-1) + (int) (rowHeight/0.6));
579
				int whereX = 0; 
575
				int whereX = 0;
580 576
				for (int i = 0; i <= SYMBOL_COLUMN_INDEX; i++) {
581
					whereX += tblLevels.getColumnModel().getColumn(i).getWidth(); 
577
					whereX += tblLevels.getColumnModel().getColumn(i).getWidth();
582 578
				}
583 579
				whereX -= 40;
584 580
				int width = 150;
......
589 585

  
590 586
				g.setColor(new Color(255, 230, 20));
591 587
				g.draw(bounds);
592
				
588

  
593 589
				g.setFont(new Font("Arial", Font.BOLD, 10));
594 590
				for (int i = 0; i < sym.getLayerCount(); i++) {
595 591
					g.setColor(Color.black);
596 592
					g.drawString(i+1+":", whereX+5, height + whereY - ( (i*rowHeight) + 5 ));
597 593
					sym.getLayer(i).drawInsideRectangle(g,
598 594
							null,
599
							new Rectangle(whereX + 20, 
595
							new Rectangle(whereX + 20,
600 596
									height + whereY - ((i+1)*rowHeight) + 3,
601
									width - 20, 
597
									width - 20,
602 598
									rowHeight - 6));
603 599
				}
604
				
600

  
605 601
			}
606 602
		};
607 603
	}
608
}  
604
}

Also available in: Unified diff