📄 doubleimagedisplay.java
字号:
/**
* DuMP3 version morpheus_0.2.9 - a duplicate/similar file finder in Java<BR>
* Copyright 2005 Alexander Grässer<BR>
* All Rights Reserved, http://dump3.sourceforge.net/<BR>
* <BR>
* This file is part of DuMP3.<BR>
* <BR>
* DuMP3 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later version.<BR>
* <BR>
* DuMP3 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.<BR>
* <BR>
* You should have received a copy of the GNU General Public License along with DuMP3; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.za.grasser.duplicate.gui.display.image;
import net.za.grasser.duplicate.file.FingerprintFile;
import net.za.grasser.duplicate.gui.display.DoubleDisplay;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import com.cloudgarden.resource.SWTResourceManager;
/**
* This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI Builder, which is free for non-commercial use. If Jigloo is being used
* commercially (ie, by a corporation, company or business for any purpose whatever) then you should purchase a license for each developer using Jigloo. Please
* visit www.cloudgarden.com for details. Use of Jigloo implies acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR THIS
* MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
/**
* This class ...
*
* @author <a href="http://sourceforge.net/sendmessage.php?touser=733840">pyropunk at sourceforge dot net</a>
* @version $Revision: 1.5 $
*/
public class DoubleImageDisplay extends DoubleDisplay {
/**
* <code>canvasLeftImage</code> DoubleImageDisplay -
*/
private SWTImageCanvas canvasLeftImage;
/**
* <code>canvasRightImage</code> DoubleImageDisplay -
*/
private SWTImageCanvas canvasRightImage;
/**
* <code>toolBarMiddle</code> DoubleImageDisplay -
*/
private ToolBar toolBarMiddle;
/**
* <code>toolItemMZoomOut</code> DoubleImageDisplay -
*/
private ToolItem toolItemMZoomOut;
/**
* <code>toolItemMZoomIn</code> DoubleImageDisplay -
*/
private ToolItem toolItemMZoomIn;
/**
* Constructor
*
* @param pArg0
* @param pArg1
*/
public DoubleImageDisplay(final Composite pArg0, final int pArg1) {
super(pArg0, pArg1);
getCanvasLeftImage();
getToolBarMiddle();
getCanvasRightImage();
}
/**
* @return canvasLeftImage
*/
public SWTImageCanvas getCanvasLeftImage() {
if (canvasLeftImage == null) {
canvasLeftImage = new SWTImageCanvas(this, SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL | SWT.H_SCROLL);
final FormData canvas5leftLData = new FormData();
canvas5leftLData.width = 63;
canvas5leftLData.height = 210;
canvas5leftLData.left = new FormAttachment(0, 1000, 0);
canvas5leftLData.right = new FormAttachment(500, 1000, -14);
canvas5leftLData.top = new FormAttachment(0, 1000, 0);
canvas5leftLData.bottom = new FormAttachment(1000, 1000, 0);
canvasLeftImage.setLayoutData(canvas5leftLData);
}
return canvasLeftImage;
}
/**
* @return canvasRightImage
*/
public SWTImageCanvas getCanvasRightImage() {
if (canvasRightImage == null) {
canvasRightImage = new SWTImageCanvas(this, SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL | SWT.H_SCROLL);
final FormData canvas5rightLData = new FormData();
canvas5rightLData.width = 63;
canvas5rightLData.height = 210;
canvas5rightLData.left = new FormAttachment(500, 1000, 14);
canvas5rightLData.right = new FormAttachment(1000, 1000, 0);
canvas5rightLData.top = new FormAttachment(0, 1000, 0);
canvas5rightLData.bottom = new FormAttachment(1000, 1000, 0);
canvasRightImage.setLayoutData(canvas5rightLData);
}
return canvasRightImage;
}
/**
* @return ToolBar
*/
public ToolBar getToolBarMiddle() {
if (toolBarMiddle == null) {
toolBarMiddle = new ToolBar(this, SWT.WRAP | SWT.BORDER | SWT.VERTICAL);
final FormData toolBar3LData = new FormData();
toolBar3LData.width = 27;
toolBar3LData.height = 112;
toolBar3LData.left = new FormAttachment(500, 1000, -14);
toolBar3LData.right = new FormAttachment(500, 1000, 14);
toolBar3LData.top = new FormAttachment(0, 1000, 0);
toolBar3LData.bottom = new FormAttachment(1000, 1000, 0);
toolBarMiddle.setLayoutData(toolBar3LData);
getToolItemMZoomIn();
getToolItemMZoomOut();
}
return toolBarMiddle;
}
/**
* @return ToolItem - Returns the toolItemMZoomOut.
*/
public ToolItem getToolItemMZoomOut() {
if (toolItemMZoomOut == null) {
toolItemMZoomOut = new ToolItem(toolBarMiddle, SWT.PUSH);
toolItemMZoomOut.setImage(SWTResourceManager.getImage("icons/mag_min.gif"));
toolItemMZoomOut.setToolTipText("zoom out");
toolItemMZoomOut.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent evt) {
toolItemMZoomOutWidgetSelected(evt);
}
});
}
return toolItemMZoomOut;
}
/**
* @return ToolItem - Returns the toolItemMZoomIn.
*/
public ToolItem getToolItemMZoomIn() {
if (toolItemMZoomIn == null) {
toolItemMZoomIn = new ToolItem(toolBarMiddle, SWT.PUSH);
toolItemMZoomIn.setImage(SWTResourceManager.getImage("icons/mag_plus.gif"));
toolItemMZoomIn.setToolTipText("zoom in");
toolItemMZoomIn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent evt) {
toolItemMZoomInWidgetSelected(evt);
}
});
}
return toolItemMZoomIn;
}
/**
* This method displays two images
*
* @param left
* @param right
*/
@Override
public void display(final FingerprintFile left, final FingerprintFile right) {
if (left == null) {
getCanvasLeftImage().unloadImage();
} else {
getCanvasLeftImage().loadImage(left.getPath());
}
if (right == null) {
getCanvasRightImage().unloadImage();
} else {
getCanvasRightImage().loadImage(right.getPath());
}
}
/**
* This method should return an instance of this class which does NOT initialize it's GUI elements. This method is ONLY required by Jigloo if the superclass
* of this class is abstract or non-public. It is not needed in any other situation.
*
* @param parent
* @param style
* @return Object
*/
public static Object getGUIBuilderInstance(final org.eclipse.swt.widgets.Composite parent, final int style) {
return new DoubleImageDisplay(parent, style, Boolean.FALSE);
}
/**
* This constructor is used by the getGUIBuilderInstance method to provide an instance of this class which has not had it's GUI elements initialized (ie,
* initGUI is not called in this constructor).
*
* @param parent
* @param style
* @param initGUI
*/
public DoubleImageDisplay(final org.eclipse.swt.widgets.Composite parent, final int style, final Boolean initGUI) {
super(parent, style);
}
/**
* This method ...
*
* @param evt
*/
void toolItemMZoomOutWidgetSelected(final SelectionEvent evt) {
getCanvasLeftImage().zoomOut();
getCanvasRightImage().zoomOut();
}
/**
* This method ...
*
* @param evt
*/
void toolItemMZoomInWidgetSelected(final SelectionEvent evt) {
getCanvasLeftImage().zoomIn();
getCanvasRightImage().zoomIn();
}
/**
* This method keeps the left and right horizontal scroll bars in synch
*
* @param img
* @param pMinimum
* @param pSelection
* @param pMaximum
*/
public void scrollX(final SWTImageCanvas img, final int pMinimum, final int pSelection, final int pMaximum) {
if (img == getCanvasLeftImage()) {
final ScrollBar r = getCanvasRightImage().getHorizontalBar();
double s = pSelection;
s /= pMaximum - pMinimum;
s *= r.getMaximum() - r.getMinimum();
s += r.getMinimum();
r.setSelection((int)s);
getCanvasRightImage().scrollHorizontally(r, false);
} else {
final ScrollBar l = getCanvasLeftImage().getHorizontalBar();
double s = pSelection;
s /= pMaximum - pMinimum;
s *= l.getMaximum() - l.getMinimum();
s += l.getMinimum();
l.setSelection((int)s);
getCanvasLeftImage().scrollHorizontally(l, false);
}
}
/**
* This method keeps the left and right vertical scroll bars in synch
*
* @param img
* @param pMinimum
* @param pSelection
* @param pMaximum
*/
public void scrollY(final SWTImageCanvas img, final int pMinimum, final int pSelection, final int pMaximum) {
if (img == getCanvasLeftImage()) {
final ScrollBar r = getCanvasRightImage().getVerticalBar();
double s = pSelection;
s /= pMaximum - pMinimum;
s *= r.getMaximum() - r.getMinimum();
s += r.getMinimum();
r.setSelection((int)s);
getCanvasRightImage().scrollVertically(r, false);
} else {
final ScrollBar r = getCanvasLeftImage().getVerticalBar();
double s = pSelection;
s /= pMaximum - pMinimum;
s *= r.getMaximum() - r.getMinimum();
s += r.getMinimum();
r.setSelection((int)s);
getCanvasLeftImage().scrollVertically(r, false);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -