class CanvasShape
{ privatefinal Color maHighlightColor = Color.red; privatefinal Color maSelectionColor = Color.green; privatefinal Color maFocusColor = Color.blue;
/** Update the data obtained from the xAccessible.
*/ publicvoid update ()
{ if (mxContext != null)
{
msName = mxContext.getAccessibleName();
msDescription = mxContext.getAccessibleDescription();
// Extract the selected and focused flag. long nStateSet = mxContext.getAccessibleStateSet ();
mbSelected = (nStateSet & AccessibleStateType.SELECTED) != 0;
mbFocused = (nStateSet & AccessibleStateType.FOCUSED) != 0;
}
updateGeometry (); if (mxComponent != null)
{ // Note: alpha values in office 0..255 have to be mapped to // 255..0 in Java
Color aCol = new Color (mxComponent.getForeground(), true);
maFgColor = new Color (aCol.getRed (),
aCol.getGreen (),
aCol.getBlue (), 0xff - aCol.getAlpha ());
aCol = new Color (mxComponent.getBackground(), true);
maBgColor = new Color (aCol.getRed (),
aCol.getGreen (),
aCol.getBlue (), 0xff - aCol.getAlpha ());
}
}
publicvoid updateGeometry ()
{ if (mxComponent != null)
{
com.sun.star.awt.Point aLocationOnScreen = mxComponent.getLocationOnScreen();
com.sun.star.awt.Size aSizeOnScreen = mxComponent.getSize();
maPosition = new Point (
aLocationOnScreen.X,
aLocationOnScreen.Y);
maSize = new Dimension (
aSizeOnScreen.Width,
aSizeOnScreen.Height);
}
}
/** Paint the object into the specified canvas. It is transformed accordingtothespecifiedoffsetandscale.
*/ publicvoid paint (Graphics2D g, double nXOffset, double nYOffset, double nScaleFactor, boolean bShowDescription, boolean bShowName, boolean bShowText)
{ try{ // Transform the object's position and size according to the // specified offset and scale.
maShape = new Rectangle2D.Double (
maPosition.x * nScaleFactor + nXOffset,
maPosition.y * nScaleFactor + nYOffset,
maSize.width * nScaleFactor,
maSize.height * nScaleFactor);
// Fill the object's bounding box with its background color if it // has no children. if (mxContext.getAccessibleChildCount() == 0)
{
g.setColor (maBgColor);
g.fill (maShape);
}
// Remove alpha channel from color before drawing the frame.
Color color = maFgColor; if (maFgColor.getAlpha()<128)
color = new Color (maFgColor.getRed(), maFgColor.getGreen(), maFgColor.getBlue());
g.setColor (color);
g.draw (maShape);
if (mbFocused)
{
g.setColor (maFocusColor); for (int x=0; x<=2; x++) for (int y=0; y<=2; y++)
g.fill ( new Rectangle2D.Double (
maShape.x + x/2.0 * maShape.width-3,
maShape.y + y/2.0 * maShape.height-3, 6, 6));
} if (mbSelected)
{
g.setColor (maSelectionColor); for (int x=0; x<=2; x++) for (int y=0; y<=2; y++)
g.draw ( new Rectangle2D.Double (
maShape.x + x/2.0 * maShape.width-2,
maShape.y + y/2.0 * maShape.height-2, 4, 4));
}
// Write the object's text OR name and description.
g.setColor (maFgColor); if (bShowName)
paintName (g); if (bShowDescription)
paintDescription (g); if (bShowText)
paintText (g);
} catch (Exception e)
{ // don't care
}
}
// Draw every character in the text string. if (xText != null)
{
String sText = xText.getText(); try
{ for(int i = 0; i < sText.length(); i++)
{
com.sun.star.awt.Rectangle aRect =
xText.getCharacterBounds(i);
double x = maShape.x + aRect.X; double y = maShape.y + aRect.Y + aRect.Height;
privatefinal AccTreeNode maNode; privatefinal XAccessibleContext mxContext; privatefinal XAccessibleComponent mxComponent; private String msDescription, msName; private Rectangle2D.Double maShape; private Point maPosition; private Dimension maSize; private Color maFgColor, maBgColor; privateboolean // Highlighting objects is an internal concept. Corresponds to selection in the tree view.
mbHighlighted, // Set when the accessible object is selected.
mbSelected, // Set when the accessible object is focused.
mbFocused;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-10-04)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.