本文整理汇总了Java中ini.trakem2.display.Display类的典型用法代码示例。如果您正苦于以下问题:Java Display类的具体用法?Java Display怎么用?Java Display使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Display类属于ini.trakem2.display包,在下文中一共展示了Display类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: currentLayer
import ini.trakem2.display.Display; //导入依赖的package包/类
private Layer currentLayer( final Object... params )
{
final Layer layer;
if ( params != null && params[ 0 ] != null )
{
final Object param = params[ 0 ];
if ( Layer.class.isInstance( param ) )
layer = ( Layer ) param;
else if ( LayerSet.class.isInstance( param ) )
layer = ( ( LayerSet ) param ).getLayer( 0 );
else if ( Displayable.class.isInstance( param ) )
layer = ( ( Displayable ) param ).getLayer();
else
layer = null;
}
else
{
final Display front = Display.getFront();
if ( front == null )
layer = Project.getProjects().get( 0 ).getRootLayerSet().getLayer( 0 );
else
layer = front.getLayer();
}
return layer;
}
示例2: setup
import ini.trakem2.display.Display; //导入依赖的package包/类
@Override
public boolean setup( final Object... params )
{
if ( params != null && params[ 0 ] != null )
{
final Object param = params[ 0 ];
if ( LayerSet.class.isInstance( param ) )
layerset = ( LayerSet ) param;
else if ( Displayable.class.isInstance( param ) )
layerset = ( ( Displayable ) param ).getLayerSet();
else
return false;
}
else
{
final Display front = Display.getFront();
if ( front == null )
layerset = Project.getProjects().get( 0 ).getRootLayerSet();
else
layerset = front.getLayerSet();
}
return true;
}
示例3: paintOnTop
import ini.trakem2.display.Display; //导入依赖的package包/类
/** Paints bounding boxes of selected objects as pink and active object as white. */
public void paintOnTop(final Graphics2D g, final Display display, final Rectangle srcRect, final double magnification) {
if (ProjectToolbar.getToolId() >= ProjectToolbar.PENCIL) { // PENCIL == SPARE2
return;
}
g.setColor(Color.pink);
Displayable active = display.getActive();
final Rectangle bbox = new Rectangle();
for (final Displayable d : display.getSelection().getSelected()) {
d.getBoundingBox(bbox);
if (d == active) {
g.setColor(Color.white);
//g.drawPolygon(d.getPerimeter());
g.drawRect(bbox.x, bbox.y, bbox.width, bbox.height);
g.setColor(Color.pink);
} else {
//g.drawPolygon(d.getPerimeter());
g.drawRect(bbox.x, bbox.y, bbox.width, bbox.height);
}
}
}
示例4: resetNonActive
import ini.trakem2.display.Display; //导入依赖的package包/类
/** Reset temporary changes such as from dragging B&C sliders and so on, in the current slice (the current Patch). */
public void resetNonActive() {
Utils.log2("PatchStack: calling reset");
// remake the awt for the patch, flush the previous awt
Loader loader = patch[currentSlice-1].getProject().getLoader();
for (int i=0; i<patch.length; i++) {
if (currentSlice-1 == i || !called[i]) continue;
called[i] = false;
ImagePlus imp = loader.fetchImagePlus(patch[i]);
ImageProcessor ip = imp.getProcessor();
switch (imp.getType()) { // as in ij.plugin.frame.ContrastAdjuster.reset(ImagePlus, ImageProcessor)
case ImagePlus.COLOR_RGB:
ip.reset(); break;
case ImagePlus.GRAY16:
case ImagePlus.GRAY32:
ip.resetMinAndMax(); break;
}
patch[i].setMinAndMax(ip.getMin(), ip.getMax());
patch[i].getProject().getLoader().decacheAWT(patch[i].getId());
Display.repaint(patch[i].getLayer(), patch[i], null, 0, true);
}
}
示例5: updateAndDraw
import ini.trakem2.display.Display; //导入依赖的package包/类
public void updateAndDraw() {
Utils.log2("PatchStack: calling updateAndDraw");
//Display.repaint(patch[currentSlice-1].getLayer(), patch[currentSlice-1], 0);
// TODO : notify listeners ?
//No, instead do it directly:
if (changes) {
saveImages(); //only those perhaps affected (can't really tell)
changes = false;
} else {
Utils.log2("PatchStack.updateAndDraw 'else'");
// decache (to force remaking) and redraw
patch[currentSlice-1].getProject().getLoader().decacheAWT(patch[currentSlice-1].getId());
Display.repaint(patch[currentSlice-1].getLayer(), patch[currentSlice-1], null, 0, true);
// reset the others if necessary
//resetNonActive(); // TODO there must to be a better way, this is overkill because not all images over which a getProcessor() has been called will have been modified. It would be solved if imp.changes was accessed through a method instead, because then I could flag the proper imp as changed
}
}
示例6: moveBlow
import ini.trakem2.display.Display; //导入依赖的package包/类
public void moveBlow(int dx, int dy) throws Exception {
int x = box.width/2 + dx;
int y = box.height/2 + dy;
// Keep within bounds
if (x < 0) x = 0;
if (y < 0) y = 0;
if (x > box.width -1) x = box.width -1;
if (y > box.height -1) y = box.height -1;
lasso.moveBlow(x, y);
// extract ROI
Roi roi = imp.getRoi();
if (null == roi) Display.getFront().getCanvas().getFakeImagePlus().setRoi(roi); // can't set to null? Java, gimme a break
else {
Roi sroi = new ShapeRoi(roi);
Rectangle b = sroi.getBounds();
sroi.setLocation(box.x + b.x, box.y + b.y);
Display.getFront().getCanvas().getFakeImagePlus().setRoi(sroi);
}
}
示例7: finish
import ini.trakem2.display.Display; //导入依赖的package包/类
public void finish(final AreaContainer ac, final AffineTransform source_aff) throws Exception {
Roi roi = imp.getRoi();
Utils.log2("roi is " + roi);
if (null == roi) return;
ShapeRoi sroi = new ShapeRoi(roi);
Rectangle b = sroi.getBounds();
sroi.setLocation(box.x + b.x, box.y + b.y);
try {
aw.getArea().add(M.getArea(sroi).createTransformedArea(source_aff.createInverse()));
ac.calculateBoundingBox(layer);
Display.getFront().getCanvas().getFakeImagePlus().killRoi();
} catch (NoninvertibleTransformException nite) {
IJError.print(nite);
}
}
示例8: addToDatabase
import ini.trakem2.display.Display; //导入依赖的package包/类
private void addToDatabase(Display display) throws Exception {
StringBuffer sb = new StringBuffer("INSERT INTO ab_displays (id, layer_id, window_x, window_y, magnification, srcrect_x, srcrect_y, srcrect_width, srcrect_height) VALUES (");
sb.append(display.getId()).append(',');
sb.append(display.getLayer().getId()).append(',');
Rectangle r = display.getBounds();
sb.append(r.x).append(',')
.append(r.y).append(',')
.append(display.getCanvas().getMagnification()).append(',')
;
r = display.getCanvas().getSrcRect();
sb.append(r.x).append(',')
.append(r.y).append(',')
.append(r.width).append(',')
.append(r.height)
;
connection.prepareStatement(sb.append(')').toString()).executeUpdate();
}
示例9: exportXML
import ini.trakem2.display.Display; //导入依赖的package包/类
/** Export the main trakem2 tag wrapping four hierarchies (the project tag, the ProjectTree, and the Top Level LayerSet the latter including all Displayable objects) and a list of displays. */
public void exportXML(final java.io.Writer writer, final String indent, final XMLOptions options) throws Exception {
Utils.showProgress(0);
// 1 - opening tag
writer.write(indent);
writer.write("<trakem2>\n");
final String in = indent + "\t";
// 2,3 - export the project itself
exportXML2(writer, in, options);
// 4 - export LayerSet hierarchy of Layer, LayerSet and Displayable objects
layer_set.exportXML(writer, in, options);
// 5 - export Display objects
Display.exportXML(this, writer, in, options);
// 6 - closing tag
writer.write("</trakem2>\n");
}
示例10: setup
import ini.trakem2.display.Display; //导入依赖的package包/类
@Override
public boolean setup( final Object... params )
{
if ( params != null && params[ 0 ] != null )
{
final Object param = params[ 0 ];
if ( LayerSet.class.isInstance( param ) )
layerset = ( LayerSet ) param;
else if ( Displayable.class.isInstance( param ) )
layerset = ( ( Displayable ) param ).getLayerSet();
else
return false;
}
else
{
final Display front = Display.getFront();
if ( front == null )
layerset = Project.getProjects().get( 0 ).getRootLayerSet();
else
layerset = front.getLayerSet();
}
return true;
}
示例11: alignSelectionTask
import ini.trakem2.display.Display; //导入依赖的package包/类
final static public Bureaucrat alignSelectionTask ( final Selection selection )
{
final Worker worker = new Worker("Aligning selected images", false, true) {
@Override
public void run() {
startedWorking();
try {
final int m = chooseAlignmentMode();
if (-1 == m)
return;
alignSelection( selection, m );
Display.repaint(selection.getLayer());
} catch (final Throwable e) {
IJError.print(e);
} finally {
finishedWorking();
}
}
@Override
public void cleanup() {
if (!selection.isEmpty())
selection.getLayer().getParent().undoOneStep();
}
};
return Bureaucrat.createAndStart( worker, selection.getProject() );
}
示例12: alignPatches
import ini.trakem2.display.Display; //导入依赖的package包/类
final static public void alignPatches(
final Align.ParamOptimize p,
final List< Patch > patches,
final Collection< Patch > fixedPatches,
final boolean tilesAreInPlaceIn,
final boolean largestGraphOnlyIn,
final boolean hideDisconnectedTilesIn,
final boolean deleteDisconnectedTilesIn,
final boolean sloppyOverlapTest )
{
final List< AbstractAffineTile2D< ? > > tiles = new ArrayList< AbstractAffineTile2D< ? > >();
final List< AbstractAffineTile2D< ? > > fixedTiles = new ArrayList< AbstractAffineTile2D< ? > > ();
Align.tilesFromPatches( p, patches, fixedPatches, tiles, fixedTiles );
transformPatchesAndVectorData(patches, new Runnable() {
@Override
public void run() {
alignTiles( p, tiles, fixedTiles, tilesAreInPlaceIn, largestGraphOnlyIn, hideDisconnectedTilesIn, deleteDisconnectedTilesIn, sloppyOverlapTest );
Display.repaint();
}
});
}
示例13: correctDistortionFromSelectionTask
import ini.trakem2.display.Display; //导入依赖的package包/类
final static public Bureaucrat correctDistortionFromSelectionTask ( final Selection selection )
{
final Worker worker = new Worker("Distortion Correction", false, true) {
@Override
public void run() {
startedWorking();
try {
correctDistortionFromSelection( selection );
Display.repaint(selection.getLayer());
} catch (final Throwable e) {
IJError.print(e);
} finally {
finishedWorking();
}
}
@Override
public void cleanup() {
if (!selection.isEmpty())
selection.getLayer().getParent().undoOneStep();
}
};
return Bureaucrat.createAndStart( worker, selection.getProject() );
}
示例14: getRoi
import ini.trakem2.display.Display; //导入依赖的package包/类
private static Rectangle getRoi( final LayerSet layerset )
{
final Roi roi;
final Display front = Display.getFront();
if ( front == null )
roi = null;
else
roi = front.getRoi();
if ( roi == null )
return new Rectangle( 0, 0, ( int ) layerset.getLayerWidth(), ( int ) layerset.getLayerHeight() );
else
return roi.getBounds();
}
示例15: mousePressed
import ini.trakem2.display.Display; //导入依赖的package包/类
public void mousePressed(final MouseEvent me) {
super.dispatcher.execSwing(new Runnable() { public void run() {
if (!me.getSource().equals(ProjectTree.this) || !project.isInputEnabled()) {
return;
}
final int x = me.getX();
final int y = me.getY();
// find the node and set it selected
final TreePath path = getPathForLocation(x, y);
if (null == path) {
return;
}
ProjectTree.this.setSelectionPath(path);
selected_node = (DefaultMutableTreeNode)path.getLastPathComponent();
if (2 == me.getClickCount() && !me.isPopupTrigger() && MouseEvent.BUTTON1 == me.getButton()) {
// show in the front Display
if (null == selected_node) return;
Object obt = selected_node.getUserObject();
if (!(obt instanceof ProjectThing)) return;
ProjectThing thing = (ProjectThing)obt;
thing.setVisible(true);
Object obd = thing.getObject();
if (obd instanceof Displayable) {
// additionaly, get the front Display (or make a new one if none) and show in it the layer in which the Displayable object is contained.
Displayable displ = (Displayable)obd;
Display.showCentered(displ.getLayer(), displ, true, me.isShiftDown());
}
return;
} else if (me.isPopupTrigger() || (ij.IJ.isMacOSX() && me.isControlDown()) || MouseEvent.BUTTON2 == me.getButton() || 0 != (me.getModifiers() & Event.META_MASK)) { // the last block is from ij.gui.ImageCanvas, aparently to make the right-click work on windows?
JPopupMenu popup = getPopupMenu(selected_node);
if (null == popup) return;
popup.show(ProjectTree.this, x, y);
return;
}
}});
}