use of java.awt.image.MemoryImageSource in project voltdb by VoltDB.
the class Transfer method _main.
/**
* @throws IllegalArgumentException for the obvious reason
*/
void _main(String[] arg) {
/*
** What function is asked from the transfer tool?
*/
iTransferMode = TRFM_TRANSFER;
if (arg != null) {
if (arg.length != 1) {
throw new IllegalArgumentException();
}
if ((arg[0].toLowerCase().equals("-r")) || (arg[0].toLowerCase().equals("--restore"))) {
iTransferMode = TRFM_RESTORE;
} else if ((arg[0].toLowerCase().equals("-d")) || (arg[0].toLowerCase().equals("--dump"))) {
iTransferMode = TRFM_DUMP;
} else if ((arg[0].toLowerCase().equals("-h")) || (arg[0].toLowerCase().equals("--help"))) {
System.out.println(Transfer.SYNTAX_MSG);
return;
} else {
throw new IllegalArgumentException();
}
}
fMain = new Frame("HSQL Transfer Tool");
imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2, 2));
fMain.setIconImage(imgEmpty);
fMain.addWindowListener(this);
fMain.setSize(640, 480);
fMain.add("Center", this);
MenuBar bar = new MenuBar();
String[] extras = { "Insert 10 rows only", "Insert 1000 rows only", "Insert all rows", "-", "Load Settings...", "Save Settings...", "-", "Exit" };
Menu menu = new Menu("Options");
addMenuItems(menu, extras);
bar.add(menu);
fMain.setMenuBar(bar);
initGUI();
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
Dimension size = fMain.getSize();
// (ulrivo): full size on screen with less than 640 width
if (d.width >= 640) {
fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
} else {
fMain.setLocation(0, 0);
fMain.setSize(d);
}
fMain.setVisible(true);
CurrentTransfer = CurrentAlter = 0;
try {
if ((iTransferMode == TRFM_DUMP) || (iTransferMode == TRFM_TRANSFER)) {
sourceDb = new TransferDb(ConnectionDialog.createConnection(fMain, "Source Database"), this);
if (!sourceDb.isConnected()) {
exit();
return;
}
} else {
FileDialog f = new FileDialog(fMain, "Restore FileName", FileDialog.LOAD);
f.show();
String sFileName = f.getFile();
String Path = f.getDirectory();
if ((sFileName == null) || (sFileName.equals(""))) {
exit();
return;
} else {
sourceDb = new TransferSQLText(Path + sFileName, this);
}
}
if ((iTransferMode == TRFM_RESTORE) || (iTransferMode == TRFM_TRANSFER)) {
targetDb = new TransferDb(ConnectionDialog.createConnection(fMain, "Target Database"), this);
if (!targetDb.isConnected()) {
exit();
return;
}
} else {
FileDialog f = new FileDialog(fMain, "Dump FileName", FileDialog.SAVE);
f.show();
String sFileName = f.getFile();
String Path = f.getDirectory();
if ((sFileName == null) || (sFileName.equals(""))) {
exit();
return;
} else {
targetDb = new TransferSQLText(Path + sFileName, this);
}
}
} catch (Exception e) {
exit();
e.printStackTrace();
return;
}
if ((iTransferMode == TRFM_DUMP) || (iTransferMode == TRFM_TRANSFER)) {
iSelectionStep = SELECT_SOURCE_CATALOG;
sSourceCatalog = null;
} else {
iSelectionStep = SELECT_DEST_CATALOG;
sDestCatalog = null;
}
ProcessNextStep();
fMain.show();
return;
}
use of java.awt.image.MemoryImageSource in project jdk8u_jdk by JetBrains.
the class Atom method Setup.
private void Setup() {
balls = new Image[nBalls];
byte[] red = new byte[256];
red[0] = (byte) bgGrey;
byte[] green = new byte[256];
green[0] = (byte) bgGrey;
byte[] blue = new byte[256];
blue[0] = (byte) bgGrey;
for (int r = 0; r < nBalls; r++) {
float b = (float) (r + 1) / nBalls;
for (int i = maxr; i >= 1; --i) {
float d = (float) i / maxr;
red[i] = (byte) blend(blend(Rl, 255, d), bgGrey, b);
green[i] = (byte) blend(blend(Gl, 255, d), bgGrey, b);
blue[i] = (byte) blend(blend(Bl, 255, d), bgGrey, b);
}
IndexColorModel model = new IndexColorModel(8, maxr + 1, red, green, blue, 0);
balls[r] = applet.createImage(new MemoryImageSource(R * 2, R * 2, model, data, 0, R * 2));
}
}
use of java.awt.image.MemoryImageSource in project bioformats by openmicroscopy.
the class LegacyQTTools method pictToImage.
/**
* Converts the given byte array in PICT format to a Java image.
*/
public synchronized Image pictToImage(byte[] bytes) throws FormatException {
checkQTLibrary();
try {
r.exec("QTSession.open()");
// Code adapted from:
// http://www.onjava.com/pub/a/onjava/2002/12/23/jmf.html?page=2
r.setVar("bytes", bytes);
r.exec("pict = new Pict(bytes)");
r.exec("box = pict.getPictFrame()");
int width = ((Integer) r.exec("box.getWidth()")).intValue();
int height = ((Integer) r.exec("box.getHeight()")).intValue();
// note: could get a RawEncodedImage from the Pict, but
// apparently no way to get a PixMap from the REI
r.exec("g = new QDGraphics(box)");
r.exec("pict.draw(g, box)");
// get data from the QDGraphics
r.exec("pixMap = g.getPixMap()");
r.exec("rei = pixMap.getPixelData()");
// copy bytes to an array
int rowBytes = ((Integer) r.exec("pixMap.getRowBytes()")).intValue();
int intsPerRow = rowBytes / 4;
int pixLen = intsPerRow * height;
r.setVar("pixLen", pixLen);
int[] pixels = new int[pixLen];
r.setVar("pixels", pixels);
r.setVar("zero", new Integer(0));
r.exec("rei.copyToArray(zero, pixels, zero, pixLen)");
// now coax into image, ignoring alpha for speed
int bitsPerSample = 32;
int redMask = 0x00ff0000;
int greenMask = 0x0000ff00;
int blueMask = 0x000000ff;
int alphaMask = 0x00000000;
DirectColorModel colorModel = new DirectColorModel(bitsPerSample, redMask, greenMask, blueMask, alphaMask);
r.exec("QTSession.close()");
return Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(width, height, colorModel, pixels, 0, intsPerRow));
} catch (ReflectException e) {
try {
r.exec("QTSession.close()");
} catch (ReflectException exc) {
LOGGER.info("Could not close QuickTime session", exc);
}
throw new FormatException("PICT extraction failed", e);
}
}
use of java.awt.image.MemoryImageSource in project clusterMaker2 by RBVI.
the class GraphicsExportPanel method drawData.
/**
* draws the data matrix
*/
public void drawData(Graphics g, int x, int y, double scale) {
if (includeData() == false)
return;
int height = (int) (getYmapHeight() * scale);
int width = (int) (getXmapWidth() * scale);
Rectangle sourceRect = new Rectangle();
sourceRect.setBounds(minArray(), minGene(), (maxArray() + 1 - minArray()), (maxGene() + 1 - minGene()));
Rectangle destRect = new Rectangle();
// HACK does not deal with discontinuous selection...
/* old version, kinda slow...
destRect.setBounds(x,y, width, height);
arrayDrawer.paint(g, sourceRect ,destRect);
*/
destRect.setBounds(0, 0, width, height);
int[] pixels = new int[width * height];
arrayDrawer.paint(pixels, sourceRect, destRect, width);
MemoryImageSource source = new MemoryImageSource(width, height, pixels, 0, width);
Image image = createImage(source);
g.drawImage(image, x, y, null);
if (includeChar()) {
try {
Image cimage = createImage(width, height);
// destRect.x += x;
// destRect.y += y;
cimage.getGraphics().drawImage(image, 0, 0, null);
((CharArrayDrawer) arrayDrawer).paintChars(cimage.getGraphics(), sourceRect, destRect);
g.drawImage(cimage, x, y, null);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Problem drawing Sequence data:" + e);
// logger.error("" + e);
// e.printStackTrace();
g.drawImage(image, x, y, null);
}
} else {
g.drawImage(image, x, y, null);
}
}
use of java.awt.image.MemoryImageSource in project clusterMaker2 by RBVI.
the class ModelViewBuffered method createNewBuffer.
private synchronized void createNewBuffer(int w, int h) {
offscreenPixels = new int[w * h];
MemoryImageSource source = new MemoryImageSource(w, h, offscreenPixels, 0, w);
source.setAnimated(true);
Image n = createImage(source);
if (offscreenBuffer != null) {
// should I be copying over pixels instead?
n.getGraphics().drawImage(offscreenBuffer, 0, 0, null);
}
offscreenBuffer = n;
offscreenGraphics = offscreenBuffer.getGraphics();
}
Aggregations