Revision 5475

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameScaleBar.java
451 451
        Rectangle2D.Double r = getBoundingBox(at);
452 452
        double numleft = m_numleft;
453 453
        initDistances();
454

  
454
        //drawOrder(g,r);
455 455
        double difDown = (rect.height / DIFDOWN);
456 456
        double difUp = (rect.height / DIFUP);
457 457
        double difL = (rect.width / DIFL);
......
665 665
        g.drawRect((int) rectotal.x, (int) rectotal.y, (int) (rectotal.width),
666 666
            (int) rectotal.height);
667 667

  
668
        drawNameUnits(g, r);
669
        drawDescription(g, r);
668
        drawNameUnitsAndDescriptions(g, r);
669
        //drawDescription(g, r);
670 670
    }
671 671

  
672 672
    /**
......
717 717
    }
718 718

  
719 719
    /**
720
     * Dibuja sobre el Graphics el nombre de la unidad de medida de la escala.
720
     * Dibuja sobre el Graphics el nombre de la unidad de medida de la escala y la descripci?n,
721
     * siendo por defecto la escala 1:.
721 722
     *
722 723
     * @param g Graphics sobre el que se dibuja.
723 724
     * @param rec Rect?ngulo que ocupa la escala gr?fica.
724 725
     */
725
    private void drawNameUnits(Graphics g, Rectangle2D.Double rec) {
726
        //	Nombre de las unidades utilizadas.
727
        Point2D.Double p = null;
726
    private void drawNameUnitsAndDescriptions(Graphics g, Rectangle2D.Double rec) {
728 727
        FontMetrics fm = g.getFontMetrics();
728
        Point2D.Double pD = null;
729
        Point2D.Double pU = null;
730
        g.setColor(textcolor);
731
   	        switch (getFormat()) {
732
   			case DUIB:
733
   				pD = new Point2D.Double(rec.getCenterX() -
734
                        (fm.stringWidth(getDescripcion()) / 2),
735
                        (rec.getMinY() + (rec.getHeight() / 9) +
736
                        (fm.getHeight() / 2)));
737
   				pU = new Point2D.Double(rec.getCenterX() -
738
   	                    (fm.stringWidth(m_nameUnit) / 2),
739
   	                    (rec.getMinY() + (rec.getHeight() / 3) +
740
   	                    (fm.getHeight() / 2)));
729 741

  
730
        if (isShowNameUnits()) {
731
            if (isAboveName()) {
732
                p = new Point2D.Double(rec.getCenterX() -
733
                        (fm.stringWidth(m_nameUnit) / 2),
734
                        (rec.getMinY() + (rec.getHeight() / 3) +
742
       	        break;
743
   			case DUBI:
744
   				pD = new Point2D.Double(rec.getCenterX() -
745
                        (fm.stringWidth(getDescripcion()) / 2),
746
                        (rec.getMinY() + (rec.getHeight() / 9) +
735 747
                        (fm.getHeight() / 2)));
736
            } else {
737
                p = new Point2D.Double(rec.getCenterX() -
738
                        (fm.stringWidth(m_nameUnit) / 2),
739
                        (rec.getMaxY() - (rec.getHeight() / 9) +
748
   				pU = new Point2D.Double(rec.getCenterX() -
749
   	                    (fm.stringWidth(m_nameUnit) / 2),
750
   	                    (rec.getMinY() + (rec.getHeight() / 3) +
751
   	                    (fm.getHeight() / 2)));
752
   				break;
753
   			case DBIU:
754
   				pD = new Point2D.Double(rec.getCenterX() -
755
                        (fm.stringWidth(getDescripcion()) / 2),
756
                        (rec.getMinY() + (rec.getHeight() / 9) +
740 757
                        (fm.getHeight() / 2)));
741
            }
742

  
743
            g.setColor(textcolor);
744
            g.drawString(m_nameUnit, (int) p.x, (int) p.y);
745
        }
746
    }
747

  
748
    /**
749
     * Dibuja sobre el Graphics la descripci?n que por defecto sera la escala.
750
     *
751
     * @param g Graphics sobre el que se dibuja.
752
     * @param rec Rect?ngulo que ocupa la escala gr?fica.
753
     */
754
    private void drawDescription(Graphics g, Rectangle2D.Double rec) {
755
        Point2D.Double p = null;
756
        FontMetrics fm = g.getFontMetrics();
757

  
758
        if (isShowDescription()) {
759
            if (isAboveDescription()) {
760
                p = new Point2D.Double(rec.getCenterX() -
758
   				pU = new Point2D.Double(rec.getCenterX() -
759
   	                     (fm.stringWidth(m_nameUnit) / 2),
760
   	                     (rec.getMaxY() - (rec.getHeight() / 9) +
761
   	                     (fm.getHeight() / 3)));
762
   				break;
763
   			case DIBU:
764
   				pD = new Point2D.Double(rec.getCenterX() -
761 765
                        (fm.stringWidth(getDescripcion()) / 2),
762 766
                        (rec.getMinY() + (rec.getHeight() / 9) +
763 767
                        (fm.getHeight() / 2)));
764
            } else {
765
                p = new Point2D.Double(rec.getCenterX() -
768
   				pU = new Point2D.Double(rec.getCenterX() -
769
   	                     (fm.stringWidth(m_nameUnit) / 2),
770
   	                     (rec.getMaxY() - (rec.getHeight() / 9) +
771
   	                     (fm.getHeight() / 3)));
772
   				break;
773
   			case UIBD:
774
   				pD = new Point2D.Double(rec.getCenterX() -
775
	                        (fm.stringWidth(getDescripcion()) / 2),
776
	                        (rec.getMaxY() - (rec.getHeight() / 9) +
777
	                        (fm.getHeight() / 3)));
778
   				pU = new Point2D.Double(rec.getCenterX() -
779
   	                    (fm.stringWidth(m_nameUnit) / 2),
780
   	                    (rec.getMinY() + (rec.getHeight() / 9) +
781
   	                    (fm.getHeight() / 2)));
782
   				break;
783
   			case UBID:
784
   				pD = new Point2D.Double(rec.getCenterX() -
766 785
                        (fm.stringWidth(getDescripcion()) / 2),
786
                        (rec.getMaxY() - (rec.getHeight() / 9) +
787
                        (fm.getHeight() / 3)));
788
   				pU = new Point2D.Double(rec.getCenterX() -
789
   	                    (fm.stringWidth(m_nameUnit) / 2),
790
   	                    (rec.getMinY() + (rec.getHeight() / 9) +
791
   	                    (fm.getHeight() / 2)));
792
   				break;
793
   			case IBUD:
794
   				pD = new Point2D.Double(rec.getCenterX() -
795
                        (fm.stringWidth(getDescripcion()) / 2),
767 796
                        (rec.getMaxY() - (rec.getHeight() / 3) +
768
                        (fm.getHeight() / 2)));
769
            }
797
                        (fm.getHeight() / 3)));
798
   				pU = new Point2D.Double(rec.getCenterX() -
799
   	                     (fm.stringWidth(m_nameUnit) / 2),
800
   	                     (rec.getMaxY() - (rec.getHeight() / 9) +
801
   	                     (fm.getHeight() / 3)));
770 802

  
771
            g.setColor(textcolor);
772
            g.drawString(getDescripcion(), (int) p.x, (int) p.y);
773
        }
803
   				break;
804
   			case BIUD:
805
   				pD = new Point2D.Double(rec.getCenterX() -
806
                        (fm.stringWidth(getDescripcion()) / 2),
807
                        (rec.getMaxY() - (rec.getHeight() / 3) +
808
                        (fm.getHeight() / 3)));
809
   				pU = new Point2D.Double(rec.getCenterX() -
810
   	                     (fm.stringWidth(m_nameUnit) / 2),
811
   	                     (rec.getMaxY() - (rec.getHeight() / 9) +
812
   	                     (fm.getHeight() / 3)));
813
   				break;
814
   			}
815
   	        if (isShowNameUnits()) {
816
   	        	g.drawString(m_nameUnit, (int) pU.x, (int) pU.y);
817
   			}
818
   	     if (isShowDescription()) {
819
	        	g.drawString(getDescripcion(), (int) pD.x, (int) pD.y);
820
	        }
774 821
    }
775

  
776 822
    /**
777 823
     * Rellena la fuente utilizada para dibujar los intervalos y la unidad de
778 824
     * medida utilizada.
......
1021 1067
     * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
1022 1068
     */
1023 1069
    public String getNameFFrame() {
1024
        return PluginServices.getText(this, "escala") + num;
1070
        return PluginServices.getText(this, "escala")+ num;
1025 1071
    }
1026 1072

  
1027 1073
    /**
......
1243 1289
		// TODO Auto-generated method stub
1244 1290

  
1245 1291
	}
1292
	private final static int DUIB=0;
1293
	private final static int DUBI=1;
1294
	private final static int DBIU=2;
1295
	private final static int DIBU=3;
1296
	private final static int UIBD=4;
1297
	private final static int UBID=5;
1298
	private final static int IBUD=6;
1299
	private final static int BIUD=7;
1300
	private int getFormat(){
1301
		if (isAboveDescription()){
1302
			if (isAboveName()){
1303
				if (isAboveIntervals()){
1304
					return DUIB;
1305
				}else{
1306
					return DUBI;
1307
				}
1308
			}else{
1309
				if (isAboveIntervals()){
1310
					return DIBU;
1311
				}else{
1312
					return DBIU;
1313
				}
1314
			}
1315
		}else{
1316
			if (isAboveName()){
1317
				if (isAboveIntervals()){
1318
					return UIBD;
1319
				}else{
1320
					return UBID;
1321
				}
1322
			}else{
1323
				if (isAboveIntervals()){
1324
					return IBUD;
1325
				}else{
1326
					return BIUD;
1327
				}
1328
			}
1329
		}
1330
	}
1246 1331
}

Also available in: Unified diff