📄 bufferedgraphictableitem2.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: BufferedGraphicTableItem2.java
package org.gudy.azureus2.ui.swt.components;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
// Referenced classes of package org.gudy.azureus2.ui.swt.components:
// BufferedTableItemImpl, BufferedGraphicTableItem, BufferedTableRow
public abstract class BufferedGraphicTableItem2 extends BufferedTableItemImpl
implements BufferedGraphicTableItem
{
private int marginHeight;
private int marginWidth;
private int orientation;
Canvas cBlockView;
private Image image;
private Color lastBackColor;
public BufferedGraphicTableItem2(BufferedTableRow row, int position)
{
BufferedTableItemImpl(row, position);
marginHeight = 1;
marginWidth = 1;
orientation = 0x1000000;
cBlockView = null;
lastBackColor = null;
}
private void createBlockView()
{
int iStyle = 0xc0000;
if (orientation == 4)
iStyle |= 0x100000;
cBlockView = new Canvas(getTable(), iStyle);
cBlockView.setBackground(null);
cBlockView.addPaintListener(new PaintListener() {
final BufferedGraphicTableItem2 this$0;
public void paintControl(PaintEvent event)
{
if (event.width == 0 || event.height == 0)
{
return;
} else
{
doPaint(event.gc.getClipping());
return;
}
}
{
this$0 = BufferedGraphicTableItem2.this;
Object();
}
});
cBlockView.addMouseListener(new MouseAdapter() {
final BufferedGraphicTableItem2 this$0;
public void mouseDown(MouseEvent e)
{
Table table = getTable();
Rectangle r = cBlockView.getBounds();
TableItem item[] = {
table.getItem(new Point(r.x, r.y))
};
if (item[0] != null)
table.setSelection(item);
table.setFocus();
}
public void mouseUp(MouseEvent e)
{
getTable().setFocus();
}
{
this$0 = BufferedGraphicTableItem2.this;
MouseAdapter();
}
});
}
public Image getGraphic()
{
return image;
}
public boolean setGraphic(Image img)
{
boolean bImageSet = image != img;
if (bImageSet)
{
if (cBlockView == null)
createBlockView();
image = img;
}
if (img != null)
doPaint((Rectangle)null);
return bImageSet;
}
public boolean needsPainting()
{
return true;
}
public void locationChanged()
{
if (cBlockView == null || cBlockView.isDisposed())
return;
Rectangle bounds = getBoundsForCanvas();
if (bounds == null || image == null || image.isDisposed())
{
return;
} else
{
cBlockView.setLocation(bounds.x, bounds.y);
return;
}
}
public void doPaint(GC gc)
{
if (cBlockView == null || cBlockView.isDisposed())
return;
Rectangle bounds = getBoundsForCanvas();
if (bounds == null || image == null || image.isDisposed())
return;
Rectangle canvasBounds = cBlockView.getBounds();
if (canvasBounds.x != bounds.x || canvasBounds.y != bounds.y)
{
cBlockView.setLocation(bounds.x, bounds.y);
canvasBounds = cBlockView.getBounds();
}
Table table = getTable();
Rectangle tableBounds = table.getClientArea();
if (tableBounds.y < table.getHeaderHeight())
tableBounds.y = table.getHeaderHeight();
Rectangle rNewCanvas = bounds.intersection(tableBounds);
if (rNewCanvas.width <= 0 || rNewCanvas.height <= 0)
return;
if (!rNewCanvas.equals(canvasBounds) || orientation != 4 && !getRowBackground(table).equals(lastBackColor))
{
rNewCanvas.x -= canvasBounds.x;
rNewCanvas.y -= canvasBounds.y;
doPaint(rNewCanvas);
}
}
public void doPaint(Rectangle clipping)
{
if (cBlockView == null || cBlockView.isDisposed())
return;
Table table = getTable();
Rectangle bounds = getBoundsForCanvas();
if (bounds == null || image == null || image.isDisposed())
return;
Rectangle canvasBounds = cBlockView.getBounds();
if (canvasBounds.x != bounds.x || canvasBounds.y != bounds.y)
{
cBlockView.setLocation(bounds.x, bounds.y);
canvasBounds = cBlockView.getBounds();
}
if (bounds.width != canvasBounds.width || bounds.height != canvasBounds.height)
{
cBlockView.setSize(bounds.width, bounds.height);
canvasBounds = cBlockView.getBounds();
}
GC gc;
if (orientation == 4)
{
Rectangle imageBounds = image.getBounds();
if (imageBounds.width != bounds.width || imageBounds.height != bounds.height)
{
cBlockView.setSize(bounds.width, bounds.height);
gc = new GC(cBlockView);
gc.drawImage(image, 0, 0, imageBounds.width, imageBounds.height, 0, 0, bounds.width, bounds.height);
gc.dispose();
invalidate();
return;
}
}
if (clipping == null)
clipping = new Rectangle(0, 0, bounds.width, bounds.height);
Rectangle tableBounds = table.getClientArea();
if (tableBounds.y < table.getHeaderHeight())
tableBounds.y = table.getHeaderHeight();
tableBounds.x -= canvasBounds.x;
tableBounds.y -= canvasBounds.y;
clipping = clipping.intersection(tableBounds);
if (clipping.x + clipping.width <= 0 && clipping.y + clipping.height <= 0)
return;
gc = new GC(cBlockView);
if (orientation == 4)
{
gc.setClipping(clipping);
gc.drawImage(image, 0, 0);
} else
{
lastBackColor = getRowBackground(table);
gc.setBackground(lastBackColor);
gc.fillRectangle(clipping);
int x = 0;
gc.setClipping(clipping);
gc.drawImage(image, x, 0);
}
gc.dispose();
}
public void dispose()
{
dispose();
image = null;
if (cBlockView != null)
{
if (!cBlockView.isDisposed())
cBlockView.dispose();
cBlockView = null;
}
}
public Rectangle getBoundsForCanvas()
{
Rectangle bounds = getBounds();
if (bounds == null)
return null;
bounds.y += marginHeight;
bounds.height -= marginHeight * 2;
bounds.x += marginWidth;
bounds.width -= marginWidth * 2;
if (bounds.width <= 0 || bounds.height <= 0)
return null;
else
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);
}
private Color getRowBackground(Table table)
{
if (!row.isSelected());
return getBackground();
}
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;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -