📄 bufferedgraphictableitem1.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: BufferedGraphicTableItem1.java
package org.gudy.azureus2.ui.swt.components;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Table;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.views.utils.VerticalAligner;
// Referenced classes of package org.gudy.azureus2.ui.swt.components:
// BufferedTableItemImpl, BufferedGraphicTableItem, BufferedTableRow
public abstract class BufferedGraphicTableItem1 extends BufferedTableItemImpl
implements BufferedGraphicTableItem
{
private int marginHeight;
private int marginWidth;
private int orientation;
private Image image;
private boolean neverDrawn;
public BufferedGraphicTableItem1(BufferedTableRow row, int position)
{
BufferedTableItemImpl(row, position);
marginHeight = 1;
marginWidth = 1;
orientation = 0x1000000;
neverDrawn = true;
}
public Image getGraphic()
{
return image;
}
public boolean setGraphic(Image img)
{
boolean bImageSet = image != img;
boolean bDoRedraw = img == null;
if (bImageSet)
{
if (!bDoRedraw && image != null && !image.isDisposed() && !img.isDisposed() && !image.getBounds().equals(img.getBounds()))
bDoRedraw = true;
image = img;
}
return bImageSet;
}
public boolean needsPainting()
{
return true;
}
private void doPaint(boolean bForceClear)
{
if (image == null || image.isDisposed())
return;
if (bForceClear || image.getImageData().getTransparencyType() != 0)
{
Table table = getTable();
Rectangle bounds = getBoundsForCanvas();
if (bounds == null)
return;
table.redraw(bounds.x, bounds.y, bounds.width, bounds.height, true);
} else
{
doPaint((GC)null);
}
}
public void doPaint(GC gc)
{
Rectangle bounds;
Rectangle imageBounds;
Rectangle clipping;
boolean ourGC;
if (neverDrawn)
{
if (gc == null)
return;
neverDrawn = false;
}
bounds = getBoundsForCanvas();
if (bounds == null || image == null || image.isDisposed())
return;
Table table = getTable();
imageBounds = image.getBounds();
if (imageBounds.width <= 0 || imageBounds.height <= 0 || bounds.width <= 0 || bounds.height <= 0)
return;
Rectangle tableBounds = table.getClientArea();
if ((bounds.y + bounds.height) - tableBounds.y < table.getHeaderHeight() || bounds.y > tableBounds.height)
return;
boolean fits = imageBounds.width == bounds.width && imageBounds.height == bounds.height;
if (orientation == 4 || fits)
{
if (fits)
{
boolean ourGC = gc == null;
if (ourGC)
gc = new GC(table);
if (gc != null)
{
int iAdj = VerticalAligner.getTableAdjustVerticalBy(table);
bounds.y += iAdj;
iAdj = VerticalAligner.getTableAdjustHorizontallyBy(table);
bounds.x += iAdj;
gc.drawImage(image, bounds.x, bounds.y);
if (ourGC)
gc.dispose();
}
return;
}
} else
{
if (imageBounds.width < bounds.width)
if (orientation == 0x1000000)
bounds.x += (bounds.width - imageBounds.width) / 2;
else
if (orientation == 0x20000)
bounds.x = (bounds.x + bounds.width) - imageBounds.width;
if (imageBounds.height < bounds.height)
bounds.y += (bounds.height - imageBounds.height) / 2;
}
clipping = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
int iMinY = table.getHeaderHeight() + tableBounds.y;
if (clipping.y < iMinY)
{
clipping.height -= iMinY - clipping.y;
clipping.y = iMinY;
}
int iMaxY = tableBounds.height + tableBounds.y;
if (clipping.y + clipping.height > iMaxY)
clipping.height = (iMaxY - clipping.y) + 1;
if (clipping.width <= 0 || clipping.height <= 0)
return;
int iAdj = VerticalAligner.getTableAdjustVerticalBy(table);
bounds.y += iAdj;
clipping.y += iAdj;
iAdj = VerticalAligner.getTableAdjustHorizontallyBy(table);
bounds.x += iAdj;
clipping.x += iAdj;
ourGC = gc == null;
if (ourGC)
gc = new GC(table);
Point srcStart = new Point(clipping.x - bounds.x, clipping.y - bounds.y);
Rectangle dstRect = new Rectangle(clipping.x, clipping.y, imageBounds.width - srcStart.x, imageBounds.height - srcStart.y);
Utils.drawImage(gc, image, srcStart, dstRect, clipping, 0, 0, false);
if (ourGC)
gc.dispose();
break MISSING_BLOCK_LABEL_704;
Exception exception;
exception;
if (ourGC)
gc.dispose();
throw exception;
}
public void dispose()
{
dispose();
image = null;
}
public Rectangle getBoundsForCanvas()
{
Rectangle bounds = getBounds();
if (bounds == null)
{
return null;
} else
{
bounds.y += marginHeight;
bounds.height -= marginHeight * 2;
bounds.x += marginWidth;
bounds.width -= marginWidth * 2;
return bounds;
}
}
public Point getSize()
{
Rectangle bounds = getBounds();
if (bounds == null)
return new Point(0, 0);
else
return new Point(bounds.width - marginWidth * 2, bounds.height - marginHeight * 2);
}
public void invalidate()
{
}
public int getMarginHeight()
{
return marginHeight;
}
public int getMarginWidth()
{
return marginWidth;
}
public void setMargin(int width, int height)
{
if (width >= 0)
marginWidth = width;
if (height >= 0)
marginHeight = height;
}
public int getOrientation()
{
return orientation;
}
public void setOrientation(int orientation)
{
this.orientation = orientation;
}
public Image getBackgroundImage()
{
Image imageRowBG = row.getBackgroundImage();
if (imageRowBG != null)
{
Rectangle bounds = getBounds();
int wInside = bounds.width - marginWidth * 2;
int hInside = bounds.height - marginHeight * 2;
Image imageCellBG = new Image(Display.getDefault(), wInside, hInside);
GC gc = new GC(imageCellBG);
gc.drawImage(imageRowBG, bounds.x + marginWidth, 0 + marginHeight, wInside, hInside, 0, 0, wInside, hInside);
gc.dispose();
return imageCellBG;
}
Table table = row.getTable();
Rectangle bounds = getBounds();
if (bounds.isEmpty())
{
return null;
} else
{
Image image = new Image(Display.getDefault(), bounds.width - marginWidth * 2, bounds.height - marginHeight * 2);
GC gc = new GC(image);
gc.setForeground(getBackground());
gc.setBackground(getBackground());
gc.fillRectangle(0, 0, bounds.width, bounds.height);
gc.dispose();
return image;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -