@@ -334,7 +334,7 @@ protected PShape parseChild(XML elem) {
334334 } else if (name .equals ("rect" )) {
335335 shape = createShape (this , elem , true );
336336 shape .parseRect ();
337-
337+
338338 } else if (name .equals ("image" )) {
339339 shape = createShape (this , elem , true );
340340 shape .parseImage ();
@@ -368,8 +368,8 @@ protected PShape parseChild(XML elem) {
368368
369369 } else if (name .equals ("text" )) { // || name.equals("font")) {
370370 return new Text (this , elem );
371-
372- } else if (name .equals ("tspan" )) {
371+
372+ } else if (name .equals ("tspan" )) {
373373 return new LineOfText (this , elem );
374374
375375 } else if (name .equals ("filter" )) {
@@ -450,8 +450,8 @@ protected void parseRect() {
450450 getFloatWithUnit (element , "height" , svgHeight )
451451 };
452452 }
453-
454-
453+
454+
455455 protected void parseImage () {
456456 kind = RECT ;
457457 textureMode = NORMAL ;
@@ -466,7 +466,7 @@ protected void parseImage() {
466466
467467 this .imagePath = element .getString ("xlink:href" );
468468 }
469-
469+
470470 /**
471471 * Parse a polyline or polygon from an SVG file.
472472 * Syntax defined at http://www.w3.org/TR/SVG/shapes.html#PointsBNF
@@ -1537,7 +1537,10 @@ public Gradient(PShapeSVG parent, XML properties) {
15371537 }
15381538
15391539
1540- public class LinearGradient extends Gradient {
1540+ // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1541+
1542+
1543+ static public class LinearGradient extends Gradient {
15411544 public float x1 , y1 , x2 , y2 ;
15421545
15431546 public LinearGradient (PShapeSVG parent , XML properties ) {
@@ -1567,7 +1570,10 @@ public LinearGradient(PShapeSVG parent, XML properties) {
15671570 }
15681571
15691572
1570- public class RadialGradient extends Gradient {
1573+ // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1574+
1575+
1576+ static public class RadialGradient extends Gradient {
15711577 public float cx , cy , r ;
15721578
15731579 public RadialGradient (PShapeSVG parent , XML properties ) {
@@ -1596,23 +1602,22 @@ public RadialGradient(PShapeSVG parent, XML properties) {
15961602
15971603
15981604 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1599-
1600- public static float TEXT_QUALITY = 1 ;
1601- protected PFont parseFont (XML properties ) {
16021605
1603- // FontFace fontFace = new FontFace(this, properties);
1606+
1607+ // static private float TEXT_QUALITY = 1;
1608+
1609+ static private PFont parseFont (XML properties ) {
16041610 String fontFamily = null ;
16051611 float size = 10 ;
16061612 int weight = PLAIN ; // 0
16071613 int italic = 0 ;
1608-
1614+
16091615 if (properties .hasAttribute ("style" )) {
16101616 String styleText = properties .getString ("style" );
16111617 String [] styleTokens = PApplet .splitTokens (styleText , ";" );
16121618
16131619 //PApplet.println(styleTokens);
16141620 for (int i = 0 ; i < styleTokens .length ; i ++) {
1615-
16161621 String [] tokens = PApplet .splitTokens (styleTokens [i ], ":" );
16171622 //PApplet.println(tokens);
16181623
@@ -1628,13 +1633,13 @@ protected PFont parseFont(XML properties) {
16281633 // setFillOpacity(tokens[1]);
16291634
16301635 } else if (tokens [0 ].equals ("font-weight" )) {
1631- // PApplet.println("font-weight: " + tokens[1]);
1632-
1633- if (tokens [1 ].contains ("bold" )) {
1634- weight = BOLD ;
1635- // PApplet.println("Bold weight ! ");
1636- }
1637-
1636+ // PApplet.println("font-weight: " + tokens[1]);
1637+
1638+ if (tokens [1 ].contains ("bold" )) {
1639+ weight = BOLD ;
1640+ // PApplet.println("Bold weight ! ");
1641+ }
1642+
16381643
16391644 } else if (tokens [0 ].equals ("font-stretch" )) {
16401645 // not supported.
@@ -1673,25 +1678,26 @@ protected PFont parseFont(XML properties) {
16731678 if (fontFamily == null ) {
16741679 return null ;
16751680 }
1676- size = size * TEXT_QUALITY ;
1681+ // size = size * TEXT_QUALITY;
16771682
16781683 return createFont (fontFamily , weight | italic , size , true );
16791684 }
16801685
1681- protected PFont createFont (String name , int weight , float size , boolean smooth ) {
1682-
1683- // System.out.println("Try to create a font of " + name + " family, " + weight);
1684- java .awt .Font baseFont = new java .awt .Font (name , weight , (int ) size ); // PFont.findFont(name);ç
16851686
1686- // System.out.println("Resulting family : " + baseFont.getFamily() + " " + baseFont.getStyle());
1687- PFont outputPFont = new PFont (baseFont .deriveFont (size ), smooth , null );
1687+ static protected PFont createFont (String name , int weight ,
1688+ float size , boolean smooth ) {
1689+ //System.out.println("Try to create a font of " + name + " family, " + weight);
1690+ java .awt .Font baseFont = new java .awt .Font (name , weight , (int ) size );
16881691
1689- // System.out.println("Resulting PFont family : " + outputPFont.getName ());
1690- return outputPFont ;
1692+ // System.out.println("Resulting family : " + baseFont.getFamily() + " " + baseFont.getStyle ());
1693+ return new PFont ( baseFont . deriveFont ( size ), smooth , null ) ;
16911694 }
16921695
1693- public static class Text extends PShapeSVG {
16941696
1697+ // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1698+
1699+
1700+ static public class Text extends PShapeSVG {
16951701 protected PFont font ;
16961702
16971703 public Text (PShapeSVG parent , XML properties ) {
@@ -1709,43 +1715,40 @@ public Text(PShapeSVG parent, XML properties) {
17091715 family = GROUP ;
17101716
17111717 font = parseFont (properties );
1712-
17131718 }
1714-
1715- // @Override
1716- // public void drawImpl(PGraphics g){
1717- // }
17181719 }
17191720
1720- public static class LineOfText extends PShapeSVG {
17211721
1722+ // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1723+
1724+
1725+ static public class LineOfText extends PShapeSVG {
17221726 String textToDisplay ;
17231727 PFont font ;
17241728
17251729 public LineOfText (PShapeSVG parent , XML properties ) {
1726-
1727- // TODO: child should ideally be parsed too...
1728- // for inline content.
1730+ // TODO: child should ideally be parsed too for inline content.
17291731 super (parent , properties , false );
17301732
1731- // // get location
1733+ // get location
17321734 float x = Float .parseFloat (properties .getString ("x" ));
17331735 float y = Float .parseFloat (properties .getString ("y" ));
17341736
17351737 float parentX = Float .parseFloat (parent .element .getString ("x" ));
17361738 float parentY = Float .parseFloat (parent .element .getString ("y" ));
1737-
1739+
17381740 if (matrix == null ) matrix = new PMatrix2D ();
17391741 matrix .translate (x - parentX , (y - parentY ) / 2f );
1740-
1741- // get the first properties
1742- parseColors (properties );
1742+
1743+ // get the first properties
1744+ parseColors (properties );
17431745 font = parseFont (properties );
17441746
1745- // It is a line..
1746- boolean isALine = properties .getString ("role" ) == "line" ;
1747- // NO inline content yet.
1747+ // cleaned up syntax but removing b/c unused [fry 190118]
1748+ // boolean isLine = properties.getString("role").equals( "line") ;
1749+
17481750 if (this .childCount > 0 ) {
1751+ // no inline content yet.
17491752 }
17501753
17511754 String text = properties .getContent ();
@@ -1762,14 +1765,18 @@ public void drawImpl(PGraphics g) {
17621765 }
17631766
17641767 pre (g );
1765- g .textFont (font , font .size / TEXT_QUALITY );
1768+ // g.textFont(font, font.size / TEXT_QUALITY);
1769+ g .textFont (font , font .size );
17661770 g .text (textToDisplay , 0 , 0 );
17671771 post (g );
17681772 }
1769-
17701773 }
1771-
1772- public static class Font extends PShapeSVG {
1774+
1775+
1776+ // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1777+
1778+
1779+ static public class Font extends PShapeSVG {
17731780 public FontFace face ;
17741781
17751782 public Map <String , FontGlyph > namedGlyphs ;
@@ -1790,8 +1797,8 @@ public Font(PShapeSVG parent, XML properties) {
17901797
17911798 horizAdvX = properties .getInt ("horiz-adv-x" , 0 );
17921799
1793- namedGlyphs = new HashMap <String , FontGlyph >();
1794- unicodeGlyphs = new HashMap <Character , FontGlyph >();
1800+ namedGlyphs = new HashMap <>();
1801+ unicodeGlyphs = new HashMap <>();
17951802 glyphCount = 0 ;
17961803 glyphs = new FontGlyph [elements .length ];
17971804
@@ -1920,7 +1927,7 @@ protected void drawShape() {
19201927 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19211928
19221929
1923- public static class FontGlyph extends PShapeSVG { // extends Path
1930+ static public class FontGlyph extends PShapeSVG { // extends Path
19241931 public String name ;
19251932 char unicode ;
19261933 int horizAdvX ;
0 commit comments