use of java.awt.geom.AffineTransform in project android_frameworks_base by AOSPA.
the class Region_Delegate method translate.
@LayoutlibDelegate
static /*package*/
void translate(Region thisRegion, int dx, int dy, Region dst) {
Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion);
if (regionDelegate == null) {
return;
}
Region_Delegate targetRegionDelegate = sManager.getDelegate(dst.mNativeRegion);
if (targetRegionDelegate == null) {
return;
}
if (regionDelegate.mArea.isEmpty()) {
targetRegionDelegate.mArea = new Area();
} else {
targetRegionDelegate.mArea = new Area(regionDelegate.mArea);
AffineTransform mtx = new AffineTransform();
mtx.translate(dx, dy);
targetRegionDelegate.mArea.transform(mtx);
}
}
use of java.awt.geom.AffineTransform in project intellij-community by JetBrains.
the class ScalableIconComponent method paintComponent.
protected void paintComponent(Graphics g) {
final Icon icon = myIsSelected ? mySelectedIcon : myIcon;
if (icon != null) {
final Graphics2D g2 = (Graphics2D) g;
g2.setBackground(getBackground());
final AffineTransform savedTransform = g2.getTransform();
g2.scale(((double) getWidth()) / icon.getIconWidth(), ((double) getHeight()) / icon.getIconHeight());
icon.paintIcon(this, g2, 0, 0);
g2.setTransform(savedTransform);
}
super.paintComponent(g);
}
use of java.awt.geom.AffineTransform in project intellij-community by JetBrains.
the class EditorGutterComponentImpl method doPaintLineNumbers.
private void doPaintLineNumbers(Graphics2D g, int startVisualLine, int endVisualLine, int offset, @NotNull TIntFunction convertor) {
int lastLine = myEditor.logicalToVisualPosition(new LogicalPosition(endLineNumber(), 0)).line;
endVisualLine = Math.min(endVisualLine, lastLine);
if (startVisualLine > endVisualLine) {
return;
}
Color color = myEditor.getColorsScheme().getColor(EditorColors.LINE_NUMBERS_COLOR);
g.setColor(color != null ? color : JBColor.blue);
Font font = getFontForLineNumbers();
g.setFont(font);
AffineTransform old = setMirrorTransformIfNeeded(g, getLineNumberAreaOffset(), getLineNumberAreaWidth());
try {
VisualLinesIterator visLinesIterator = new VisualLinesIterator(myEditor, startVisualLine);
while (!visLinesIterator.atEnd() && visLinesIterator.getVisualLine() <= endVisualLine) {
LogicalPosition logicalPosition = myEditor.visualToLogicalPosition(new VisualPosition(visLinesIterator.getVisualLine(), 0));
if (EditorUtil.getSoftWrapCountAfterLineStart(myEditor, logicalPosition) <= 0) {
int logLine = convertor.execute(visLinesIterator.getStartLogicalLine());
if (logLine >= 0) {
int startY = visLinesIterator.getY();
if (myEditor.isInDistractionFreeMode()) {
Color fgColor = myTextFgColors.get(visLinesIterator.getVisualLine());
g.setColor(fgColor != null ? fgColor : color != null ? color : JBColor.blue);
}
String s = String.valueOf(logLine + 1);
int textOffset = isMirrored() ? offset - getLineNumberAreaWidth() - 1 : offset - g.getFontMetrics().stringWidth(s);
g.drawString(s, textOffset, startY + myEditor.getAscent());
}
}
visLinesIterator.advance();
}
} finally {
if (old != null)
g.setTransform(old);
}
}
use of java.awt.geom.AffineTransform in project intellij-community by JetBrains.
the class EditorGutterComponentImpl method setMirrorTransformIfNeeded.
@Nullable
private AffineTransform setMirrorTransformIfNeeded(Graphics2D g, int offset, int width) {
if (isMirrored()) {
AffineTransform old = g.getTransform();
AffineTransform transform = new AffineTransform(old);
//transform.translate(getWidth(), 0); // revert mirroring transform
//transform.scale(-1, 1); // revert mirroring transform
//transform.translate(getWidth() - offset - width, 0); // move range start to the X==0
//transform.translate(-offset, 0);
transform.scale(-1, 1);
transform.translate(-offset * 2 - width, 0);
g.setTransform(transform);
return old;
} else {
return null;
}
}
use of java.awt.geom.AffineTransform in project intellij-community by JetBrains.
the class EditorGutterComponentImpl method paintAnnotations.
private void paintAnnotations(Graphics2D g, int startVisualLine, int endVisualLine) {
int x = getAnnotationsAreaOffset();
int w = getAnnotationsAreaWidthEx();
if (w == 0)
return;
AffineTransform old = setMirrorTransformIfNeeded(g, x, w);
try {
Color color = myEditor.getColorsScheme().getColor(EditorColors.ANNOTATIONS_COLOR);
g.setColor(color != null ? color : JBColor.blue);
g.setFont(myEditor.getColorsScheme().getFont(EditorFontType.PLAIN));
for (int i = 0; i < myTextAnnotationGutters.size(); i++) {
TextAnnotationGutterProvider gutterProvider = myTextAnnotationGutters.get(i);
int lineHeight = myEditor.getLineHeight();
int lastLine = myEditor.logicalToVisualPosition(new LogicalPosition(endLineNumber(), 0)).line;
endVisualLine = Math.min(endVisualLine, lastLine);
if (startVisualLine > endVisualLine) {
break;
}
int annotationSize = myTextAnnotationGutterSizes.get(i);
VisualLinesIterator visLinesIterator = new VisualLinesIterator(myEditor, startVisualLine);
while (!visLinesIterator.atEnd() && visLinesIterator.getVisualLine() <= endVisualLine) {
int logLine = visLinesIterator.getStartLogicalLine();
int y = visLinesIterator.getY();
String s = gutterProvider.getLineText(logLine, myEditor);
final EditorFontType style = gutterProvider.getStyle(logLine, myEditor);
final Color bg = gutterProvider.getBgColor(logLine, myEditor);
if (bg != null) {
g.setColor(bg);
g.fillRect(x, y, annotationSize, lineHeight);
}
g.setColor(myEditor.getColorsScheme().getColor(gutterProvider.getColor(logLine, myEditor)));
g.setFont(myEditor.getColorsScheme().getFont(style));
if (!StringUtil.isEmpty(s)) {
// we leave half of the gap before the text
g.drawString(s, GAP_BETWEEN_ANNOTATIONS / 2 + x, y + myEditor.getAscent());
}
visLinesIterator.advance();
}
if (startVisualLine == 0 && endVisualLine == 0) {
//allow paining gutters for empty documents
String s = gutterProvider.getLineText(0, myEditor);
final EditorFontType style = gutterProvider.getStyle(0, myEditor);
final Color bg = gutterProvider.getBgColor(0, myEditor);
if (bg != null) {
g.setColor(bg);
g.fillRect(x, 0, annotationSize, lineHeight);
}
g.setColor(myEditor.getColorsScheme().getColor(gutterProvider.getColor(0, myEditor)));
g.setFont(myEditor.getColorsScheme().getFont(style));
if (!StringUtil.isEmpty(s)) {
g.drawString(s, GAP_BETWEEN_ANNOTATIONS / 2 + x, myEditor.getAscent());
}
}
x += annotationSize;
}
} finally {
if (old != null)
g.setTransform(old);
}
}
Aggregations