Revision 4226 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/v02/FGraphicUtilities.java
FGraphicUtilities.java | ||
---|---|---|
427 | 427 |
|
428 | 428 |
AffineTransform Tx = (AffineTransform) ant.clone(); |
429 | 429 |
Tx.translate(x, y); // S3: final translation |
430 |
Tx.rotate(Math.toRadians(-theLabel.getRotation())); // S2: rotate around anchor
|
|
430 |
Tx.rotate(theLabel.getRotation()); // S2: rotate around anchor
|
|
431 | 431 |
g2.setTransform(Tx); |
432 | 432 |
|
433 | 433 |
switch (theLabel.getJustification()) { |
... | ... | |
492 | 492 |
* @param theSymbol S?mbolo para aplicar. |
493 | 493 |
* @param theLabel FLabel que contiene el texto que se debe dibujar. |
494 | 494 |
*/ |
495 |
public static void DrawLabel2(Graphics2D g2, ViewPort vp, FShape shp,
|
|
496 |
FSymbol theSymbol, FLabel theLabel,FTextLayout textLayout) {
|
|
495 |
public static void DrawLabel2(Graphics2D g2, ViewPort vp, |
|
496 |
FSymbol theSymbol, FLabel theLabel,FontMetrics metrics) {
|
|
497 | 497 |
//float angle; |
498 | 498 |
float x; |
499 | 499 |
float y; |
500 | 500 |
Point2D pAux = null; |
501 |
|
|
502 |
// USAR TEXTLAYOUT SI QUEREMOS PERMITIR SELECCIONAR UN TEXTO |
|
503 |
// Y/O EDITARLO "IN SITU" |
|
504 |
|
|
505 |
/* if (m_labelValues[numReg].length() > 0) |
|
506 |
{ |
|
507 |
TextLayout layout = new TextLayout(m_labelValues[numReg], font, frc); |
|
508 |
layout.draw(g2, x, y); |
|
509 |
} */ |
|
510 |
if (shp == null) { |
|
511 |
return; |
|
512 |
} |
|
513 |
|
|
514 | 501 |
// Las etiquetas que pongamos a nulo ser? porque no la queremos dibujar. |
515 | 502 |
// ?til para cuando queramos eliminar duplicados. |
516 | 503 |
if (theLabel.getString() == null) { |
517 | 504 |
return; |
518 | 505 |
} |
519 | 506 |
|
520 |
//FontMetrics metrics = g2.getFontMetrics(); |
|
521 |
//int width = metrics.stringWidth(theLabel.getString()); |
|
522 |
//int height = metrics.getMaxAscent(); |
|
523 |
|
|
524 |
// int height = metrics.getHeight(); |
|
525 | 507 |
g2.setFont(theSymbol.getFont()); |
526 | 508 |
g2.setColor(theSymbol.getFontColor()); |
527 | 509 |
|
... | ... | |
545 | 527 |
//width = g2.getFontMetrics().stringWidth(theLabel.getString()); |
546 | 528 |
} |
547 | 529 |
|
548 |
int type=shp.getShapeType(); |
|
549 |
if (shp.getShapeType()>=FShape.Z){ |
|
550 |
type=shp.getShapeType()-FShape.Z; |
|
551 |
} |
|
552 |
switch (type) { |
|
553 |
case FShape.POINT: //Tipo punto |
|
554 |
pAux = new Point2D.Double(((FPoint2D) shp).getX(), |
|
555 |
((FPoint2D) shp).getY()); |
|
556 |
pAux = vp.getAffineTransform().transform(pAux, null); |
|
530 |
pAux = vp.getAffineTransform().transform(theLabel.getOrig(), null); |
|
557 | 531 |
|
558 |
break; |
|
559 |
} |
|
560 |
|
|
561 | 532 |
AffineTransform ant = g2.getTransform(); |
562 | 533 |
|
563 | 534 |
x = (float) pAux.getX(); |
... | ... | |
565 | 536 |
|
566 | 537 |
AffineTransform Tx = (AffineTransform) ant.clone(); |
567 | 538 |
Tx.translate(x, y); // S3: final translation |
568 |
Tx.rotate(Math.toRadians(-theLabel.getRotation())); // S2: rotate around anchor
|
|
539 |
Tx.rotate(theLabel.getRotation()); // S2: rotate around anchor
|
|
569 | 540 |
g2.setTransform(Tx); |
570 |
Point2D p=new Point2D.Double(0,0); |
|
571 |
Rectangle2D borde=textLayout.getBoundingBox(p,theLabel.getJustification(),g2);//theLabel.getBoundingBox(); |
|
572 |
textLayout.draw(g2,theLabel.getJustification()); |
|
573 |
g2.setColor(Color.blue); |
|
574 |
g2.drawRect((int)borde.getX(),(int)borde.getY(),(int)borde.getWidth(),(int)borde.getHeight()); |
|
541 |
// Rectangle2D borde=textLayout.getBoundingBox(theLabel.getOrig(),theLabel.getJustification(),g2,vp);//theLabel.getBoundingBox(); |
|
542 |
///textLayout.draw(g2,theLabel.getJustification()); |
|
543 |
//g2.setColor(Color.blue); |
|
544 |
// g2.drawRect((int)borde.getX(),(int)borde.getY(),(int)borde.getWidth(),(int)borde.getHeight()); |
|
575 | 545 |
|
576 |
//if (textLayout.isSelected()){ |
|
546 |
String s=theLabel.getString(); |
|
547 |
float width = metrics.stringWidth(s); |
|
548 |
float height = metrics.getMaxAscent(); |
|
549 |
switch (theLabel.getJustification()) { |
|
577 | 550 |
|
551 |
case FLabel.LEFT_BOTTOM: |
|
552 |
g2.drawString(s, 0, 0 - 3); |
|
578 | 553 |
|
579 |
//} |
|
580 |
|
|
581 |
/*switch (theLabel.getJustification()) { |
|
582 |
case FLabel.LEFT_BOTTOM: |
|
583 |
textLayout.draw(g2,0,-3); |
|
584 | 554 |
break; |
555 |
|
|
585 | 556 |
case FLabel.LEFT_CENTER: |
586 |
textLayout.draw(g2,0,-(height/2)); |
|
557 |
g2.drawString(s, 0, 0 - (height / 2)); |
|
558 |
|
|
587 | 559 |
break; |
560 |
|
|
588 | 561 |
case FLabel.LEFT_TOP: |
589 |
textLayout.draw(g2,0,-height); |
|
562 |
g2.drawString(s, 0, 0 - height); |
|
563 |
|
|
590 | 564 |
break; |
565 |
|
|
591 | 566 |
case FLabel.CENTER_BOTTOM: |
592 |
textLayout.draw(g2,-(width/2),-3); |
|
567 |
g2.drawString(s, 0 - (width / 2), 0 - 3); |
|
568 |
|
|
593 | 569 |
break; |
570 |
|
|
594 | 571 |
case FLabel.CENTER_CENTER: |
595 |
textLayout.draw(g2,-(width/2),-(height/2)); |
|
572 |
g2.drawString(s, 0 - (width / 2), |
|
573 |
0 - (height / 2)); |
|
574 |
|
|
596 | 575 |
break; |
576 |
|
|
597 | 577 |
case FLabel.CENTER_TOP: |
598 |
textLayout.draw(g2,-(width/2),-height); |
|
578 |
g2.drawString(s, 0 - (width / 2), 0 - |
|
579 |
height); |
|
580 |
|
|
599 | 581 |
break; |
582 |
|
|
600 | 583 |
case FLabel.RIGHT_BOTTOM: |
601 |
textLayout.draw(g2,-width,-3); |
|
584 |
g2.drawString(s, 0 - width, 0 - 3); |
|
585 |
|
|
602 | 586 |
break; |
587 |
|
|
603 | 588 |
case FLabel.RIGHT_CENTER: |
604 |
textLayout.draw(g2,-width,-(height/2)); |
|
589 |
g2.drawString(s, 0 - width, 0 - |
|
590 |
(height / 2)); |
|
591 |
|
|
605 | 592 |
break; |
593 |
|
|
606 | 594 |
case FLabel.RIGHT_TOP: |
607 |
textLayout.draw(g2,-width,-height); |
|
595 |
g2.drawString(s, 0 - width, 0 - height); |
|
596 |
|
|
608 | 597 |
break; |
609 | 598 |
} |
610 |
*/ |
|
611 | 599 |
// Restauramos |
612 | 600 |
g2.setTransform(ant); |
613 | 601 |
} |
Also available in: Unified diff