quickimage

16:51:07.621 INFO  jd.cli.Main - Decompiling quickimage.jar
package nu.psnet.quickimage;

import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class QuickImagePlugin
  extends AbstractUIPlugin
{
  private static QuickImagePlugin plugin;
  public static final String PLUGIN_ID = "nu.psnet.quickimage.editors.QuickImageEditor";
  
  public QuickImagePlugin()
  {
    plugin = this;
  }
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    super.stop(context);
  }
  
  public static QuickImagePlugin getDefault()
  {
    return plugin;
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.QuickImagePlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.core;

import java.io.File;
import java.io.FileFilter;

class ImageFileFilter
  implements FileFilter
{
  String[] patterns = { ".gif", ".jpeg", ".jpg", ".png", ".ico", ".bmp" };
  
  public boolean accept(File f)
  {
    for (int i = 0; i < patterns.length; i++) {
      if (f.getName().toLowerCase().endsWith(patterns[i])) {
        return true;
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.core.ImageFileFilter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.core;

import java.io.File;
import nu.psnet.quickimage.editors.QuickImageEditor;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;

public class ImageHolder
{
  private Image thumb;
  private Image fullsize;
  private IStorage storage;
  private File file;
  private String displayName = null;
  private Display display;
  private final int space = 16;
  private int absx;
  private int absy = 0;
  private final Point dim = new Point(140, 160);
  private boolean selected = false;
  private Color COLOR_GRAY;
  private Color COLOR_DARKBLUE;
  private QManager manager;
  private double imageSize = 0.0D;
  static Font font;
  
  public ImageHolder(QManager manager, Display display)
  {
    this.manager = manager;
    this.display = display;
    COLOR_GRAY = display.getSystemColor(16);
    COLOR_DARKBLUE = display.getSystemColor(31);
    if (font == null)
    {
      try
      {
        font = new Font(display, "", 8, 0);
      }
      catch (Exception localException)
      {
        font = display.getSystemFont();
      }
      dim.y = (dim.x + font.getFontData()[0].getHeight() + 10);
    }
  }
  
  public Point getThumbDimension()
  {
    return dim;
  }
  
  public void drawThumb(GC gc, int inX, int inY)
  {
    int x = inX;
    int y = inY;
    try
    {
      if (thumb == null) {
        initThumb();
      }
      Color c = gc.getForeground();
      if (isSelected())
      {
        gc.setLineWidth(3);
        gc.setForeground(COLOR_DARKBLUE);
      }
      else
      {
        gc.setForeground(COLOR_GRAY);
      }
      Rectangle rect = new Rectangle(x + 8, y + 8, dim.x - 16, dim.x - 16);
      Rectangle rectClip = new Rectangle(x - 2, y - 2, width + 4, dim.y);
      gc.setClipping(rectClip);
      
      gc.drawRectangle(rect);
      
      gc.setFont(font);
      gc.setForeground(display.getSystemColor(2));
      gc.drawString(getDisplayName(), x, y + height + 2, true);
      
      absx = x;
      absy = y;
      x += dim.x / 2 - thumb.getBounds().width / 2;
      y += dim.x / 2 - thumb.getBounds().height / 2;
      gc.drawImage(thumb, x, y);
      gc.setLineWidth(1);
      gc.setForeground(c);
    }
    catch (RuntimeException localRuntimeException)
    {
      replaceWithCannotDisplayImage();
      drawThumb(gc, inX, inY);
    }
  }
  
  public boolean mouseClickedOver(int x, int y)
  {
    return (x > absx) && (x < absx + dim.x) && (y > absy) && (y < absy + dim.y);
  }
  
  public void drawFullsize(GC gc, int inX, int inY)
  {
    int x = inX;
    int y = inY;
    try
    {
      if ((fullsize == null) || (fullsize.isDisposed())) {
        initFullsize();
      }
      gc.drawImage(fullsize, x, y);
    }
    catch (RuntimeException localRuntimeException)
    {
      replaceWithCannotDisplayImage();
      drawFullsize(gc, inX, inY);
    }
  }
  
  public IStorage getStorage()
  {
    return storage;
  }
  
  public void setStorage(IStorage storage)
  {
    this.storage = storage;
    setDisplayName(storage.getName());
  }
  
  public double getImageSize()
  {
    return imageSize;
  }
  
  public void setFile(File file)
  {
    this.file = file;
    setDisplayName(file.getName());
    imageSize = (file.length() / 1024.0D);
  }
  
  private void initFullsize()
    throws RuntimeException
  {
    if ((fullsize != null) && (!fullsize.isDisposed())) {
      fullsize.dispose();
    }
    ImageData data = null;
    if (file != null) {
      data = new ImageData(file.getAbsolutePath());
    } else {
      try
      {
        data = new ImageData(storage.getContents());
      }
      catch (CoreException e)
      {
        throw new RuntimeException("Could not load image from IStorage: " + e.getMessage());
      }
    }
    fullsize = new Image(display, data);
  }
  
  public Image getFullsize()
  {
    try
    {
      if ((fullsize == null) || (fullsize.isDisposed())) {
        initFullsize();
      }
    }
    catch (RuntimeException localRuntimeException)
    {
      replaceWithCannotDisplayImage();
      initFullsize();
    }
    return fullsize;
  }
  
  public boolean hasFullsize()
  {
    if ((fullsize != null) && (!fullsize.isDisposed())) {
      return true;
    }
    return false;
  }
  
  private void initThumb()
  {
    if (thumb != null) {
      thumb.dispose();
    }
    ImageData data = new ImageData(file.getAbsolutePath());
    float w = 0.0F;
    float h = 0.0F;
    boolean doscale = false;
    if (height > dim.x - 32)
    {
      doscale = true;
      h = (height - (dim.x - 32)) / height;
    }
    if (width > dim.x - 32)
    {
      doscale = true;
      w = (width - (dim.x - 32)) / width;
    }
    if (doscale)
    {
      float scale = Math.max(w, h);
      w = width - width * scale;
      h = height - height * scale;
      if (w < 1.0F) {
        w = 1.0F;
      }
      if (h < 1.0F) {
        h = 1.0F;
      }
      data = data.scaledTo((int)w, (int)h);
    }
    thumb = new Image(display, data);
  }
  
  public void dispose()
  {
    if ((fullsize != null) && (!fullsize.isDisposed())) {
      fullsize.dispose();
    }
    if ((thumb != null) && (!thumb.isDisposed())) {
      thumb.dispose();
    }
  }
  
  public boolean isSelected()
  {
    return selected;
  }
  
  public void setSelected(boolean selected)
  {
    this.selected = selected;
  }
  
  public String getDisplayName()
  {
    return displayName;
  }
  
  public void setDisplayName(String displayName)
  {
    this.displayName = displayName;
  }
  
  private void replaceWithCannotDisplayImage()
  {
    try
    {
      dispose();
      fullsize = null;
      thumb = null;
      String tmpName = getDisplayName();
      setFile(new File(manager.getImageEditor().getIconsdir() + "broken_image.gif"));
      setDisplayName(tmpName + " (image could not be displayed)");
    }
    catch (Exception localException)
    {
      manager.getImageOrganizer().removeHolder(this);
    }
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.core.ImageHolder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.core;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import nu.psnet.quickimage.editors.QuickImageEditor;
import org.eclipse.core.resources.IStorage;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;

public class ImageOrganizer
{
  public static final int VIEW_THUMB = 0;
  public static final int VIEW_FULLSIZE = 1;
  public String path;
  public String filename;
  private int index = 0;
  private ArrayList<ImageHolder> holders = new ArrayList();
  private Display display;
  private int activeView = 1;
  private QManager manager;
  
  public ImageOrganizer(QManager manager, Display display)
  {
    this.manager = manager;
    this.display = display;
  }
  
  public void setStorage(IStorage storage)
  {
    path = null;
    filename = null;
    holders.clear();
    ImageHolder holder = new ImageHolder(manager, display);
    holder.setStorage(storage);
    holders.add(holder);
  }
  
  public void setPath(String path, String filename)
  {
    this.path = path;
    this.filename = filename;
    initList();
  }
  
  private ImageHolder holder(int index)
  {
    return (ImageHolder)holders.get(index);
  }
  
  public void removeHolder(ImageHolder holder)
  {
    holders.remove(holder);
    while ((index >= holders.size()) && (index > 0)) {
      index -= 1;
    }
    manager.getImageEditor().setPartName(getCurrent().getDisplayName());
  }
  
  public void removeHolder(int index)
  {
    holders.remove(index);
    while ((index >= holders.size()) && (index > 0)) {
      index--;
    }
  }
  
  public ImageHolder getNext()
  {
    if ((holder(index).getFullsize() != null) && (!holder(index).getFullsize().isDisposed())) {
      holder(index).getFullsize().dispose();
    }
    index = ((index + 1) % holders.size());
    
    return holder(index);
  }
  
  public int getCount()
  {
    return holders.size();
  }
  
  public boolean isSingle()
  {
    return getHolders().size() == 1;
  }
  
  public ArrayList<ImageHolder> getHolders()
  {
    return holders;
  }
  
  public ImageHolder getPrevious()
  {
    if ((holder(index).getFullsize() != null) && (!holder(index).getFullsize().isDisposed())) {
      holder(index).getFullsize().dispose();
    }
    if (index > 0) {
      index -= 1;
    }
    return holder(index);
  }
  
  public boolean hasNext()
  {
    return holders.size() - 1 != index;
  }
  
  public boolean hasPrevious()
  {
    return index != 0;
  }
  
  public ImageHolder getCurrent()
  {
    return holder(index);
  }
  
  public int getTotalWidth()
  {
    return 0;
  }
  
  private void initList()
  {
    File f = new File(path);
    File[] files = f.listFiles(new ImageFileFilter());
    if (files != null)
    {
      String[] sfiles = new String[files.length];
      for (int i = 0; i < files.length; i++) {
        sfiles[i] = files[i].getAbsolutePath();
      }
      Arrays.sort(sfiles, String.CASE_INSENSITIVE_ORDER);
      for (int i = 0; i < sfiles.length; i++)
      {
        if (sfiles[i].endsWith(filename)) {
          index = i;
        }
        ImageHolder h = new ImageHolder(manager, display);
        h.setFile(new File(sfiles[i]));
        holders.add(h);
      }
    }
  }
  
  public Point getThumbWidth()
  {
    if (holders == null) {
      return new Point(1, 1);
    }
    return holder(0).getThumbDimension();
  }
  
  public int getActiveView()
  {
    return activeView;
  }
  
  public void setActiveView(int activeView)
  {
    this.activeView = activeView;
  }
  
  public boolean selectHolder(int x, int y)
  {
    boolean tmp = false;
    boolean found = false;
    for (int i = 0; i < holders.size(); i++)
    {
      tmp = holder(i).mouseClickedOver(x, y);
      if ((tmp) && (!found))
      {
        if ((holder(index).hasFullsize()) && (!holder(index).getFullsize().isDisposed())) {
          holder(index).getFullsize().dispose();
        }
        index = i;
        found = true;
        holder(i).setSelected(true);
      }
      else
      {
        holder(i).setSelected(false);
      }
    }
    return found;
  }
  
  public void setCurrentToSelected()
  {
    for (int i = 0; i < holders.size(); i++) {
      if (holder(i).isSelected())
      {
        holder(index).getFullsize().dispose();
        holder(i).setSelected(false);
      }
    }
    getCurrent().setSelected(true);
  }
  
  public void setSelectedToCurrent()
  {
    for (int i = 0; i < holders.size(); i++) {
      if (holder(i).isSelected())
      {
        holder(index).getFullsize().dispose();
        index = i;
        break;
      }
    }
  }
  
  public void dispose()
  {
    for (int i = 0; i < holders.size(); i++) {
      holder(i).dispose();
    }
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.core.ImageOrganizer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.core;

import nu.psnet.quickimage.editors.QuickImageEditor;
import nu.psnet.quickimage.widgets.QStatusCanvas;
import nu.psnet.quickimage.widgets.QuickImageCanvas;

public class QManager
{
  private QuickImageCanvas imageCanvas;
  private QStatusCanvas statusCanvas;
  private ImageOrganizer imageOrganizer;
  private QuickImageEditor imageEditor;
  
  public QuickImageCanvas getImageCanvas()
  {
    return imageCanvas;
  }
  
  public void setImageCanvas(QuickImageCanvas imageCanvas)
  {
    this.imageCanvas = imageCanvas;
  }
  
  public QuickImageEditor getImageEditor()
  {
    return imageEditor;
  }
  
  public void setImageEditor(QuickImageEditor imageEditor)
  {
    this.imageEditor = imageEditor;
  }
  
  public ImageOrganizer getImageOrganizer()
  {
    return imageOrganizer;
  }
  
  public void setImageOrganizer(ImageOrganizer imageOrganizer)
  {
    this.imageOrganizer = imageOrganizer;
  }
  
  public QStatusCanvas getStatusCanvas()
  {
    return statusCanvas;
  }
  
  public void setStatusCanvas(QStatusCanvas statusCanvas)
  {
    this.statusCanvas = statusCanvas;
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.core.QManager
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.editors;

import nu.psnet.quickimage.core.QManager;
import nu.psnet.quickimage.widgets.QuickImageCanvas;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.ToolItem;

class QuickImageEditor$1
  extends SelectionAdapter
{
  QuickImageEditor$1(QuickImageEditor paramQuickImageEditor) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    QuickImageEditor.access$0(this$0).setSelection(false);
    QuickImageEditor.access$1(this$0).getImageCanvas().rotate();
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.editors.QuickImageEditor.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.editors;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class QuickImageEditor$2
  extends SelectionAdapter
{
  QuickImageEditor$2(QuickImageEditor paramQuickImageEditor) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    QuickImageEditor.access$2(this$0, e);
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.editors.QuickImageEditor.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.editors;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class QuickImageEditor$3
  extends SelectionAdapter
{
  QuickImageEditor$3(QuickImageEditor paramQuickImageEditor) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    QuickImageEditor.access$3(this$0, e);
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.editors.QuickImageEditor.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.editors;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class QuickImageEditor$4
  extends SelectionAdapter
{
  QuickImageEditor$4(QuickImageEditor paramQuickImageEditor) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.toggleView();
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.editors.QuickImageEditor.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.editors;

import nu.psnet.quickimage.core.QManager;
import nu.psnet.quickimage.widgets.QuickImageCanvas;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.ToolItem;

class QuickImageEditor$5
  extends SelectionAdapter
{
  QuickImageEditor$5(QuickImageEditor paramQuickImageEditor) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    QuickImageEditor.access$0(this$0).setSelection(false);
    QuickImageEditor.access$1(this$0).getImageCanvas().zoomIn();
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.editors.QuickImageEditor.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.editors;

import nu.psnet.quickimage.core.QManager;
import nu.psnet.quickimage.widgets.QuickImageCanvas;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.ToolItem;

class QuickImageEditor$6
  extends SelectionAdapter
{
  QuickImageEditor$6(QuickImageEditor paramQuickImageEditor) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    QuickImageEditor.access$0(this$0).setSelection(false);
    QuickImageEditor.access$1(this$0).getImageCanvas().zoomOut();
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.editors.QuickImageEditor.6
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.editors;

import nu.psnet.quickimage.core.QManager;
import nu.psnet.quickimage.widgets.QuickImageCanvas;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class QuickImageEditor$7
  extends SelectionAdapter
{
  QuickImageEditor$7(QuickImageEditor paramQuickImageEditor) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    QuickImageEditor.access$1(this$0).getImageCanvas().zoomFit();
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.editors.QuickImageEditor.7
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.editors;

import nu.psnet.quickimage.core.QManager;
import nu.psnet.quickimage.widgets.QuickImageCanvas;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.ToolItem;

class QuickImageEditor$8
  extends SelectionAdapter
{
  QuickImageEditor$8(QuickImageEditor paramQuickImageEditor) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    QuickImageEditor.access$0(this$0).setSelection(false);
    QuickImageEditor.access$1(this$0).getImageCanvas().zoomOriginal();
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.editors.QuickImageEditor.8
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.editors;

import nu.psnet.quickimage.core.QManager;
import nu.psnet.quickimage.widgets.QuickImageCanvas;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.widgets.ToolItem;

class QuickImageEditor$9
  extends ControlAdapter
{
  QuickImageEditor$9(QuickImageEditor paramQuickImageEditor) {}
  
  public void controlResized(ControlEvent e)
  {
    if (QuickImageEditor.access$0(this$0).getSelection()) {
      QuickImageEditor.access$1(this$0).getImageCanvas().zoomFit();
    }
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.editors.QuickImageEditor.9
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.editors;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import nu.psnet.quickimage.QuickImagePlugin;
import nu.psnet.quickimage.core.ImageHolder;
import nu.psnet.quickimage.core.ImageOrganizer;
import nu.psnet.quickimage.core.QManager;
import nu.psnet.quickimage.widgets.QStatusCanvas;
import nu.psnet.quickimage.widgets.QuickImageCanvas;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IStorageEditorInput;
import org.eclipse.ui.editors.text.ILocationProvider;
import org.eclipse.ui.part.EditorPart;
import org.eclipse.ui.part.FileEditorInput;
import org.osgi.framework.Bundle;

public class QuickImageEditor
  extends EditorPart
{
  private ToolItem previous;
  private ToolItem next;
  private ToolItem rotate;
  private ToolItem zoomIn;
  private ToolItem zoomOut;
  private ToolItem zoomOrg;
  private ToolItem zoomFit;
  private ToolItem view;
  private Image viewThumb;
  private Image viewFullsize;
  private Composite parent;
  private String iconsdir = null;
  private QManager manager;
  
  public void createPartControl(Composite parent)
  {
    this.parent = parent;
    
    manager = new QManager();
    manager.setImageOrganizer(new ImageOrganizer(manager, parent.getDisplay()));
    manager.setImageEditor(this);
    try
    {
      iconsdir = (Platform.resolve(QuickImagePlugin.getDefault().getBundle().getEntry("/")).getFile() + "icons" + File.separator);
    }
    catch (IOException localIOException) {}
    IEditorInput editorInput = getEditorInput();
    if ((editorInput instanceof FileEditorInput))
    {
      FileEditorInput fileEditorInput = (FileEditorInput)getEditorInput();
      IEditorInput file = getEditorInput();
      setPartName(file.getName());
      
      manager.getImageOrganizer().setPath(fileEditorInput.getPath().removeLastSegments(1).toOSString(), fileEditorInput.getName());
    }
    else if (editorInput.getAdapter(ILocationProvider.class) != null)
    {
      ILocationProvider location = (ILocationProvider)editorInput.getAdapter(ILocationProvider.class);
      IPath path = location.getPath(editorInput);
      setPartName(editorInput.getName());
      manager.getImageOrganizer().setPath(path.removeLastSegments(1).toOSString(), editorInput.getName());
    }
    else if ((editorInput instanceof IStorageEditorInput))
    {
      IStorageEditorInput storageEditorInput = (IStorageEditorInput)editorInput;
      try
      {
        IStorage storage = storageEditorInput.getStorage();
        setPartName(storage.getName());
        manager.getImageOrganizer().setStorage(storage);
      }
      catch (CoreException e)
      {
        e.printStackTrace();
      }
    }
    else if (editorInput.getAdapter(IFile.class) != null)
    {
      IFile file = (IFile)editorInput.getAdapter(IFile.class);
      setPartName(file.getName());
      manager.getImageOrganizer().setPath(file.getLocation().removeLastSegments(1).toOSString(), file.getName());
    }
    initElements();
    
    manager.getImageOrganizer().setActiveView(1);
    manager.getImageCanvas().setIconsPath(iconsdir);
    manager.getImageCanvas().updateFullsizeData();
    manager.getStatusCanvas().updateWithCurrent();
  }
  
  private void initElements()
  {
    FormLayout layout = new FormLayout();
    Composite compos = new Composite(parent, 0);
    compos.setLayout(layout);
    compos.setLayoutData(new FormData());
    FormData toolbarData = new FormData();
    
    manager.setImageCanvas(new QuickImageCanvas(manager, compos, 0));
    manager.setStatusCanvas(new QStatusCanvas(manager, compos, 0));
    
    ToolBar toolBar = new ToolBar(compos, 8388608);
    toolBar.setLayoutData(toolbarData);
    
    previous = new ToolItem(toolBar, 8388608);
    previous.setToolTipText("Previous Image");
    previous.setImage(new Image(parent.getDisplay(), iconsdir + "previous.gif"));
    previous.setSelection(true);
    
    next = new ToolItem(toolBar, 8388608);
    next.setToolTipText("Next Image");
    next.setImage(new Image(parent.getDisplay(), iconsdir + "next.gif"));
    
    rotate = new ToolItem(toolBar, 8388608);
    rotate.setToolTipText("Rotate");
    rotate.setImage(new Image(parent.getDisplay(), iconsdir + "rotate.gif"));
    
    viewThumb = new Image(parent.getDisplay(), iconsdir + "thumb.gif");
    viewFullsize = new Image(parent.getDisplay(), iconsdir + "fullsize.gif");
    view = new ToolItem(toolBar, 8388608);
    view.setToolTipText("view Thumbnails");
    view.setImage(viewThumb);
    
    new ToolItem(toolBar, 2);
    
    zoomIn = new ToolItem(toolBar, 8388608);
    zoomIn.setToolTipText("zoom in");
    zoomIn.setImage(new Image(parent.getDisplay(), iconsdir + "zoom_in.gif"));
    
    zoomOut = new ToolItem(toolBar, 8388608);
    zoomOut.setToolTipText("zoom out");
    zoomOut.setImage(new Image(parent.getDisplay(), iconsdir + "zoom_out.gif"));
    
    zoomOrg = new ToolItem(toolBar, 8388608);
    zoomOrg.setToolTipText("zoom original size");
    zoomOrg.setImage(new Image(parent.getDisplay(), iconsdir + "zoom_100.gif"));
    
    zoomFit = new ToolItem(toolBar, 32);
    zoomFit.setToolTipText("fit image in window");
    zoomFit.setImage(new Image(parent.getDisplay(), iconsdir + "zoom_fit.gif"));
    
    FormData canvasData = new FormData();
    
    manager.getImageCanvas().setLayoutData(canvasData);
    
    FormData statusData = new FormData();
    
    manager.getStatusCanvas().setLayoutData(statusData);
    
    top = new FormAttachment(toolBar, 0);
    bottom = new FormAttachment(100, -18);
    right = new FormAttachment(100, 0);
    left = new FormAttachment(0, 0);
    
    top = new FormAttachment(0, 0);
    left = new FormAttachment(0, 0);
    right = new FormAttachment(100, 0);
    
    top = new FormAttachment(manager.getImageCanvas(), 0);
    bottom = new FormAttachment(100, 0);
    right = new FormAttachment(100, 0);
    left = new FormAttachment(0, 0);
    
    rotate.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        zoomFit.setSelection(false);
        manager.getImageCanvas().rotate();
      }
    });
    previous.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        QuickImageEditor.this.clickedPrevious(e);
      }
    });
    next.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        QuickImageEditor.this.clickedNext(e);
      }
    });
    view.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        toggleView();
      }
    });
    zoomIn.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        zoomFit.setSelection(false);
        manager.getImageCanvas().zoomIn();
      }
    });
    zoomOut.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        zoomFit.setSelection(false);
        manager.getImageCanvas().zoomOut();
      }
    });
    zoomFit.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        manager.getImageCanvas().zoomFit();
      }
    });
    zoomOrg.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        zoomFit.setSelection(false);
        manager.getImageCanvas().zoomOriginal();
      }
    });
    manager.getImageCanvas().addControlListener(new ControlAdapter()
    {
      public void controlResized(ControlEvent e)
      {
        if (zoomFit.getSelection()) {
          manager.getImageCanvas().zoomFit();
        }
      }
    });
    previous.setEnabled(manager.getImageOrganizer().hasPrevious());
    next.setEnabled(manager.getImageOrganizer().hasNext());
    if (manager.getImageOrganizer().isSingle())
    {
      next.setEnabled(false);
      previous.setEnabled(false);
      view.setEnabled(false);
    }
  }
  
  public void dispose()
  {
    manager.getImageOrganizer().dispose();
    manager.getImageCanvas().dispose();
    manager.getStatusCanvas().dispose();
    
    super.dispose();
  }
  
  public void toggleView()
  {
    if (manager.getImageOrganizer().getActiveView() == 1)
    {
      previous.setEnabled(false);
      next.setEnabled(false);
      rotate.setEnabled(false);
      manager.getImageOrganizer().setActiveView(0);
      manager.getImageOrganizer().setCurrentToSelected();
      view.setImage(viewFullsize);
      view.setToolTipText("View Fullsize");
      view.setEnabled(false);
      view.setEnabled(true);
      zoomIn.setEnabled(false);
      zoomOut.setEnabled(false);
      zoomFit.setEnabled(false);
      zoomOrg.setEnabled(false);
    }
    else
    {
      previous.setEnabled(manager.getImageOrganizer().hasPrevious());
      next.setEnabled(manager.getImageOrganizer().hasNext());
      rotate.setEnabled(true);
      manager.getImageOrganizer().setActiveView(1);
      
      view.setImage(viewThumb);
      view.setToolTipText("View Thumbnails");
      manager.getImageCanvas().updateFullsizeData();
      view.setEnabled(false);
      view.setEnabled(true);
      zoomIn.setEnabled(true);
      zoomOut.setEnabled(true);
      zoomFit.setSelection(false);
      zoomFit.setEnabled(true);
      zoomOrg.setEnabled(true);
    }
    manager.getImageCanvas().updateThumbData();
  }
  
  private void clickedPrevious(SelectionEvent e)
  {
    manager.getImageOrganizer().getPrevious();
    manager.getImageCanvas().updateFullsizeData();
    manager.getStatusCanvas().updateWithCurrent();
    setPartName(manager.getImageOrganizer().getCurrent().getDisplayName());
    previous.setEnabled(manager.getImageOrganizer().hasPrevious());
    next.setEnabled(manager.getImageOrganizer().hasNext());
  }
  
  private void clickedNext(SelectionEvent e)
  {
    manager.getImageOrganizer().getNext();
    manager.getImageCanvas().updateFullsizeData();
    manager.getStatusCanvas().updateWithCurrent();
    setPartName(manager.getImageOrganizer().getCurrent().getDisplayName());
    previous.setEnabled(manager.getImageOrganizer().hasPrevious());
    next.setEnabled(manager.getImageOrganizer().hasNext());
  }
  
  public void setPartName(String s)
  {
    super.setPartName(s);
  }
  
  public void init(IEditorSite site, IEditorInput input)
  {
    setSite(site);
    setInput(input);
  }
  
  public void setFocus()
  {
    if (manager.getImageCanvas() != null) {
      manager.getImageCanvas().setFocus();
    }
  }
  
  public void doSave(IProgressMonitor monitor) {}
  
  public void doSaveAs() {}
  
  public boolean isDirty()
  {
    return false;
  }
  
  public boolean isSaveAsAllowed()
  {
    return false;
  }
  
  public String getIconsdir()
  {
    return iconsdir;
  }
  
  public void setIconsdir(String iconsdir)
  {
    this.iconsdir = iconsdir;
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.editors.QuickImageEditor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.widgets;

import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;

class QStatusCanvas$1
  implements PaintListener
{
  QStatusCanvas$1(QStatusCanvas paramQStatusCanvas) {}
  
  public void paintControl(PaintEvent event)
  {
    this$0.paint(gc);
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.widgets.QStatusCanvas.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.widgets;

import java.text.DecimalFormat;
import nu.psnet.quickimage.core.ImageHolder;
import nu.psnet.quickimage.core.ImageOrganizer;
import nu.psnet.quickimage.core.QManager;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;

public class QStatusCanvas
  extends Canvas
{
  private String filesize = "";
  private int height = 0;
  private int width = 0;
  private String filename = "";
  private int depth = 0;
  private Image image;
  private DecimalFormat df = new DecimalFormat("0.000");
  private Color COLOR_DARK_GRAY;
  private QManager manager;
  
  public QStatusCanvas(QManager manager, Composite parent, int style)
  {
    super(parent, style | 0x800000);
    this.manager = manager;
    
    addPaintListener(new PaintListener()
    {
      public void paintControl(PaintEvent event)
      {
        paint(gc);
      }
    });
    COLOR_DARK_GRAY = parent.getDisplay().getSystemColor(16);
  }
  
  public void updateWithCurrent()
  {
    if (manager.getImageOrganizer().getActiveView() == 1)
    {
      image = manager.getImageOrganizer().getCurrent().getFullsize();
      if (image != null)
      {
        depth = image.getImageData().depth;
        width = image.getBounds().width;
        height = image.getBounds().height;
      }
    }
    ImageHolder holder = manager.getImageOrganizer().getCurrent();
    filename = holder.getDisplayName();
    filesize = df.format(holder.getImageSize());
    if (holder.getImageSize() == 0.0D) {
      filesize = "unknown";
    }
    redraw();
  }
  
  void paint(GC gc)
  {
    if (manager.getImageOrganizer().getActiveView() == 1)
    {
      gc.drawString("Size (kb): " + filesize, 5, 1);
      gc.drawString("Depth: " + depth, 140, 1);
      gc.drawString(width + " x " + height, 225, 1);
      gc.drawString("Name: " + filename, 325, 1);
      gc.setForeground(COLOR_DARK_GRAY);
      gc.drawLine(135, 0, 135, 24);
      gc.drawLine(210, 0, 210, 24);
      gc.drawLine(320, 0, 320, 24);
    }
    else
    {
      gc.drawString("Size (kb): " + filesize, 5, 1);
      gc.drawString("Name: " + filename, 140, 1);
      gc.setForeground(COLOR_DARK_GRAY);
      gc.drawLine(135, 0, 135, 24);
    }
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.widgets.QStatusCanvas
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.widgets;

import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;

class QuickImageCanvas$1
  extends ControlAdapter
{
  QuickImageCanvas$1(QuickImageCanvas paramQuickImageCanvas) {}
  
  public void controlResized(ControlEvent e)
  {
    QuickImageCanvas.access$0(this$0);
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.widgets.QuickImageCanvas.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.widgets;

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;

class QuickImageCanvas$2
  implements MouseListener
{
  QuickImageCanvas$2(QuickImageCanvas paramQuickImageCanvas) {}
  
  public void mouseDoubleClick(MouseEvent e)
  {
    QuickImageCanvas.access$1(this$0, e);
  }
  
  public void mouseDown(MouseEvent e)
  {
    QuickImageCanvas.access$2(this$0, e);
  }
  
  public void mouseUp(MouseEvent e)
  {
    QuickImageCanvas.access$3(this$0, false);
    this$0.setCursor(QuickImageCanvas.access$4(this$0));
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.widgets.QuickImageCanvas.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.widgets;

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;

class QuickImageCanvas$3
  implements MouseMoveListener
{
  QuickImageCanvas$3(QuickImageCanvas paramQuickImageCanvas) {}
  
  public void mouseMove(MouseEvent e)
  {
    if (QuickImageCanvas.access$5(this$0)) {
      QuickImageCanvas.access$6(this$0, e);
    }
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.widgets.QuickImageCanvas.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.widgets;

import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;

class QuickImageCanvas$4
  implements PaintListener
{
  QuickImageCanvas$4(QuickImageCanvas paramQuickImageCanvas) {}
  
  public void paintControl(PaintEvent event)
  {
    this$0.paint(gc);
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.widgets.QuickImageCanvas.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.widgets;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.ScrollBar;

class QuickImageCanvas$5
  extends SelectionAdapter
{
  QuickImageCanvas$5(QuickImageCanvas paramQuickImageCanvas) {}
  
  public void widgetSelected(SelectionEvent event)
  {
    QuickImageCanvas.access$7(this$0, (ScrollBar)widget);
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.widgets.QuickImageCanvas.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.widgets;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.ScrollBar;

class QuickImageCanvas$6
  extends SelectionAdapter
{
  QuickImageCanvas$6(QuickImageCanvas paramQuickImageCanvas) {}
  
  public void widgetSelected(SelectionEvent event)
  {
    QuickImageCanvas.access$8(this$0, (ScrollBar)widget);
  }
}

/* Location:
 * Qualified Name:     nu.psnet.quickimage.widgets.QuickImageCanvas.6
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package nu.psnet.quickimage.widgets;

import java.util.ArrayList;
import nu.psnet.quickimage.core.ImageHolder;
import nu.psnet.quickimage.core.ImageOrganizer;
import nu.psnet.quickimage.core.QManager;
import nu.psnet.quickimage.editors.QuickImageEditor;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.PaletteData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ScrollBar;

public class QuickImageCanvas
  extends Canvas
{
  private Image originalImage;
  private Image workingImage;
  private Image backImage;
  private Composite parent;
  private int clientw;
  private int clienth;
  private int imgx;
  private int imgy;
  private int imgw;
  private int imgh;
  private int scrolly;
  private int scrollx;
  private int mousex;
  private int mousey = 1;
  private Color COLOR_WIDGET_BACKGROUND;
  private boolean listenForMouseMovement = false;
  private Cursor handOpen;
  private Cursor handClosed;
  private double zoomScale = 1.0D;
  private QManager manager;
  
  public QuickImageCanvas(QManager manager, Composite parent, int style)
  {
    super(parent, style | 0x800 | 0x40000 | 0x200 | 0x100);
    
    this.manager
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd