private MarkerData.GlyphMarker makeGlyphMarker(StrutMetrics strutMetrics) { int diameter = (int) ((strutMetrics.getAscent() + strutMetrics.getDescent()) / 3); MarkerData.GlyphMarker result = new MarkerData.GlyphMarker(); result.setDiameter(diameter); result.setLayoutWidth(diameter * 3); return result; }
private static int getReferenceBaseline(RenderingContext c, BlockBox box) { MarkerData markerData = box.getMarkerData(); StrutMetrics strutMetrics = box.getMarkerData().getStructMetrics(); if (markerData.getReferenceLine() != null) { return markerData.getReferenceLine().getAbsY() + strutMetrics.getBaseline(); } else { return box.getAbsY() + box.getTy() + strutMetrics.getBaseline(); } }
private MarkerData.ImageMarker makeImageMarker( LayoutContext c, StrutMetrics structMetrics, String image) { FSImage img = null; if (! image.equals("none")) { img = c.getUac().getImageResource(image).getImage(); if (img != null) { StrutMetrics strutMetrics = structMetrics; if (img.getHeight() > strutMetrics.getAscent()) { img.scale(-1, (int) strutMetrics.getAscent()); } MarkerData.ImageMarker result = new MarkerData.ImageMarker(); result.setImage(img); result.setLayoutWidth(img.getWidth() * 2); return result; } } return null; }
public static StrutMetrics createDefaultStrutMetrics(LayoutContext c, Box container) { FSFontMetrics strutM = container.getStyle().getFSFontMetrics(c); InlineBoxMeasurements measurements = getInitialMeasurements(c, container, strutM); return new StrutMetrics( strutM.getAscent(), measurements.getBaseline(), strutM.getDescent()); }
strutMetrics.setBaseline(measurements.getBaseline() - vaContext.getInlineTop()); markerData.setReferenceLine(current); current.setMarkerData(markerData);
private MarkerData.ImageMarker makeImageMarker( LayoutContext c, StrutMetrics structMetrics, String image) { FSImage img = null; if (! image.equals("none")) { img = c.getUac().getImageResource(image).getImage(); if (img != null) { StrutMetrics strutMetrics = structMetrics; if (img.getHeight() > strutMetrics.getAscent()) { img.scale(-1, (int) strutMetrics.getAscent()); } MarkerData.ImageMarker result = new MarkerData.ImageMarker(); result.setImage(img); result.setLayoutWidth(img.getWidth() * 2); return result; } } return null; }
public static StrutMetrics createDefaultStrutMetrics(LayoutContext c, Box container) { FSFontMetrics strutM = container.getStyle().getFSFontMetrics(c); InlineBoxMeasurements measurements = getInitialMeasurements(c, container, strutM); return new StrutMetrics( strutM.getAscent(), measurements.getBaseline(), strutM.getDescent()); }
strutMetrics.setBaseline(measurements.getBaseline() - vaContext.getInlineTop()); markerData.setReferenceLine(current); current.setMarkerData(markerData);
private MarkerData.GlyphMarker makeGlyphMarker(StrutMetrics strutMetrics) { int diameter = (int) ((strutMetrics.getAscent() + strutMetrics.getDescent()) / 3); MarkerData.GlyphMarker result = new MarkerData.GlyphMarker(); result.setDiameter(diameter); result.setLayoutWidth(diameter * 3); return result; }
private static void drawImage(RenderingContext c, BlockBox box, MarkerData markerData) { FSImage img = null; MarkerData.ImageMarker marker = markerData.getImageMarker(); img = marker.getImage(); if (img != null) { StrutMetrics strutMetrics = box.getMarkerData().getStructMetrics(); int x = getReferenceX(c, box); // FIXME: findbugs possible loss of precision, cf. int / (float)2 x += -marker.getLayoutWidth() + (marker.getLayoutWidth() / 2 - img.getWidth() / 2); c.getOutputDevice().drawImage(img, x, (int)(getReferenceBaseline(c, box) - strutMetrics.getAscent() / 2 - img.getHeight() / 2)); } }
private static int getReferenceBaseline(RenderingContext c, BlockBox box) { MarkerData markerData = box.getMarkerData(); StrutMetrics strutMetrics = box.getMarkerData().getStructMetrics(); if (markerData.getReferenceLine() != null) { return markerData.getReferenceLine().getAbsY() + strutMetrics.getBaseline(); } else { return box.getAbsY() + box.getTy() + strutMetrics.getBaseline(); } }
private static void drawImage(RenderingContext c, BlockBox box, MarkerData markerData) { FSImage img = null; MarkerData.ImageMarker marker = markerData.getImageMarker(); img = marker.getImage(); if (img != null) { StrutMetrics strutMetrics = box.getMarkerData().getStructMetrics(); int x = getReferenceX(c, box); x += -marker.getLayoutWidth() + (marker.getLayoutWidth() / 2 - img.getWidth() / 2); c.getOutputDevice().drawImage(img, x, (int)(getReferenceBaseline(c, box) - strutMetrics.getAscent() / 2 - img.getHeight() / 2)); } }
private static void drawGlyph(RenderingContext c, BlockBox box, CalculatedStyle style, IdentValue listStyle) { // save the old AntiAliasing setting, then force it on Object aa_key = c.getOutputDevice().getRenderingHint(RenderingHints.KEY_ANTIALIASING); c.getOutputDevice().setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // calculations for bullets StrutMetrics strutMetrics = box.getMarkerData().getStructMetrics(); MarkerData.GlyphMarker marker = box.getMarkerData().getGlyphMarker(); int x = getReferenceX(c, box); x += -marker.getLayoutWidth(); int y = getReferenceBaseline(c, box) - (int)strutMetrics.getAscent() / 2 - marker.getDiameter() / 2; if (listStyle == IdentValue.DISC) { c.getOutputDevice().fillOval(x, y, marker.getDiameter(), marker.getDiameter()); } else if (listStyle == IdentValue.SQUARE) { c.getOutputDevice().fillRect(x, y, marker.getDiameter(), marker.getDiameter()); } else if (listStyle == IdentValue.CIRCLE) { c.getOutputDevice().drawOval(x, y, marker.getDiameter(), marker.getDiameter()); } // restore the old AntiAliasing setting c.getOutputDevice().setRenderingHint(RenderingHints.KEY_ANTIALIASING, aa_key == null ? RenderingHints.VALUE_ANTIALIAS_DEFAULT : aa_key); }
private static void drawGlyph(RenderingContext c, BlockBox box, CalculatedStyle style, IdentValue listStyle) { // save the old AntiAliasing setting, then force it on Object aa_key = c.getOutputDevice().getRenderingHint(RenderingHints.KEY_ANTIALIASING); c.getOutputDevice().setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // calculations for bullets StrutMetrics strutMetrics = box.getMarkerData().getStructMetrics(); MarkerData.GlyphMarker marker = box.getMarkerData().getGlyphMarker(); int x = getReferenceX(c, box); x += -marker.getLayoutWidth(); int y = getReferenceBaseline(c, box) - (int)strutMetrics.getAscent() / 2 - marker.getDiameter() / 2; if (listStyle == IdentValue.DISC) { c.getOutputDevice().fillOval(x, y, marker.getDiameter(), marker.getDiameter()); } else if (listStyle == IdentValue.SQUARE) { c.getOutputDevice().fillRect(x, y, marker.getDiameter(), marker.getDiameter()); } else if (listStyle == IdentValue.CIRCLE) { c.getOutputDevice().drawOval(x, y, marker.getDiameter(), marker.getDiameter()); } // restore the old AntiAliasing setting c.getOutputDevice().setRenderingHint(RenderingHints.KEY_ANTIALIASING, aa_key == null ? RenderingHints.VALUE_ANTIALIAS_DEFAULT : aa_key); }