use of javax.swing.text.View in project Spark by igniterealtime.
the class ChatPrinter method printView.
private boolean printView(Graphics2D graphics2D, Shape allocation, View view) {
boolean pageExists = false;
Rectangle clipRectangle = graphics2D.getClipBounds();
Shape childAllocation;
View childView;
if (view.getViewCount() > 0) {
for (int i = 0; i < view.getViewCount(); i++) {
childAllocation = view.getChildAllocation(i, allocation);
if (childAllocation != null) {
childView = view.getView(i);
if (printView(graphics2D, childAllocation, childView)) {
pageExists = true;
}
}
}
} else {
// I
if (allocation.getBounds().getMaxY() >= clipRectangle.getY()) {
pageExists = true;
// II
if ((allocation.getBounds().getHeight() > clipRectangle.getHeight()) && (allocation.intersects(clipRectangle))) {
view.paint(graphics2D, allocation);
} else {
// III
if (allocation.getBounds().getY() >= clipRectangle.getY()) {
if (allocation.getBounds().getMaxY() <= clipRectangle.getMaxY()) {
view.paint(graphics2D, allocation);
} else {
// IV
if (allocation.getBounds().getY() < pageEndY) {
pageEndY = allocation.getBounds().getY();
}
}
}
}
}
}
return pageExists;
}
use of javax.swing.text.View in project freeplane by freeplane.
the class ZoomableLabel method getLink.
public String getLink(Point p) {
View view = (View) getClientProperty(BasicHTML.propertyKey);
if (view == null)
return null;
Rectangle textR = ((ZoomableLabelUI) getUI()).getTextR(this);
if (textR == null)
return null;
if (!textR.contains(p))
return null;
int x = (int) (p.x / getZoom());
int y = (int) (p.y / getZoom());
final int pos = view.viewToModel(x, y, textR);
final HTMLDocument document = (HTMLDocument) view.getDocument();
final String linkURL = HtmlUtils.getURLOfExistingLink(document, pos);
return linkURL;
}
use of javax.swing.text.View in project freeplane by freeplane.
the class ZoomableLabelUI method propertyChange.
@Override
public void propertyChange(PropertyChangeEvent e) {
String name = e.getPropertyName();
if (name == "text" || "font" == name || "foreground" == name || "ancestor" == name || "graphicsConfiguration" == name) {
JLabel lbl = ((JLabel) e.getSource());
if (getTextRenderingIcon(lbl) != null) {
ScaledHTML.updateRenderer(lbl, "");
} else {
String text = lbl.getText();
GlyphPainterMetricResetter.resetPainter();
try {
ScaledHTML.updateRenderer(lbl, text);
} finally {
GlyphPainterMetricResetter.resetPainter();
}
View v = (View) lbl.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
lbl.putClientProperty("preferredWidth", v.getPreferredSpan(View.X_AXIS));
}
}
} else
super.propertyChange(e);
}
use of javax.swing.text.View in project Zong by Xenoage.
the class TextEditor method computeOptimumSize.
/**
* Computes the optimum size of this {@link TextEditor} in px.
*/
public Size2f computeOptimumSize() {
View v = this.getUI().getRootView(this);
v.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE);
return new Size2f(v.getPreferredSpan(View.X_AXIS), v.getPreferredSpan(View.Y_AXIS));
}
use of javax.swing.text.View in project LauncherV3 by TechnicPack.
the class FixRunDataDialog method getPreferredSize.
private java.awt.Dimension getPreferredSize(String html, int width) {
resizer.setText(html);
View view = (View) resizer.getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey);
view.setSize(width, 0);
float w = view.getPreferredSpan(View.X_AXIS);
float h = view.getPreferredSpan(View.Y_AXIS);
return new java.awt.Dimension((int) Math.ceil(w), (int) Math.ceil(h));
}
Aggregations