pl.netanel.swt.matrix.reloaded
Class CellImageButtonPainter<X extends java.lang.Number,Y extends java.lang.Number>

java.lang.Object
  extended by pl.netanel.swt.matrix.Painter<X,Y>
      extended by pl.netanel.swt.matrix.reloaded.CellImageButtonPainter<X,Y>
Direct Known Subclasses:
Grouping.CellPainter

public class CellImageButtonPainter<X extends java.lang.Number,Y extends java.lang.Number>
extends Painter<X,Y>

Paints an image in the cell. Get cell indexes when given coordinates are inside the cell image. Toggle image


Field Summary
 
Fields inherited from class pl.netanel.swt.matrix.Painter
availableTextArea, collapsedImage, expanded, expandedImage, extent, frozenX, frozenY, gc, hasChildren, image, imagesAfter, imagesBefore, isSelected, NAME_BACKGORUND, NAME_CELLS, NAME_DRAG_ITEM_X, NAME_DRAG_ITEM_Y, NAME_EMBEDDED_CONTROLS, NAME_EMULATED_CONTROLS, NAME_FOCUS_CELL, NAME_FREEZE_HEAD_LINE_X, NAME_FREEZE_HEAD_LINE_Y, NAME_FREEZE_TAIL_LINE_X, NAME_FREEZE_TAIL_LINE_Y, NAME_FROZEN_HEAD_HEAD, NAME_FROZEN_HEAD_NONE, NAME_FROZEN_HEAD_TAIL, NAME_FROZEN_NONE_HEAD, NAME_FROZEN_NONE_NONE, NAME_FROZEN_NONE_TAIL, NAME_FROZEN_TAIL_HEAD, NAME_FROZEN_TAIL_NONE, NAME_FROZEN_TAIL_TAIL, NAME_LINES_X, NAME_LINES_Y, nodeImageSize, SCOPE_CELLS, SCOPE_CELLS_ITEM_X, SCOPE_CELLS_ITEM_Y, SCOPE_CELLS_X, SCOPE_CELLS_Y, SCOPE_ENTIRE, SCOPE_LINES_X, SCOPE_LINES_Y, selectionHighlight, style, text, textLayout
 
Constructor Summary
CellImageButtonPainter(java.lang.String name, Image buttonImage)
          Creates push button behavior using the given image as the button.
CellImageButtonPainter(java.lang.String name, Image trueImage, Image falseImage)
          Creates toggle button behavior and displaying trueImage when getToggleState(Number, Number) returns Boolean.TRUE, falseImage when Boolean.FALSE and nothing when it returns null.
 
Method Summary
 java.lang.Boolean getToggleState(X indexX, Y indexY)
          Returns a three state toggle status of the given cell with the following consequences: null - no image displayed true - trueImage displayed false - falseImage displayed
 boolean isOverImage(int x, int y)
          Returns true if coordinates are over the image of drawn by this painter, or false otherwise.
 void setToggleImages(Image trueImage, Image falseImage)
           
 void setupSpatial(X indexX, Y indexY)
          Overrides the default method setting the image related to toggle state.
 
Methods inherited from class pl.netanel.swt.matrix.Painter
align, clean, clipText, computeSize, computeTextSize, dispose, getData, getImageAt, getName, getScope, getZone, hasTreeLinesVisible, init, isEnabled, isTreeEnabled, paint, setData, setEnabled, setNodeImages, setTreeLinesVisible, setTreeVisible, setup, trackPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CellImageButtonPainter

public CellImageButtonPainter(java.lang.String name,
                              Image trueImage,
                              Image falseImage)
Creates toggle button behavior and displaying trueImage when getToggleState(Number, Number) returns Boolean.TRUE, falseImage when Boolean.FALSE and nothing when it returns null.

Parameters:
name - name of the painter
trueImage - image to display when the toggle is set to true
falseImage - image to display when the toggle is set to false

CellImageButtonPainter

public CellImageButtonPainter(java.lang.String name,
                              Image buttonImage)
Creates push button behavior using the given image as the button.

Parameters:
name - name of the painter
buttonImage - image to emulate the button
Method Detail

setToggleImages

public void setToggleImages(Image trueImage,
                            Image falseImage)

getToggleState

public java.lang.Boolean getToggleState(X indexX,
                                        Y indexY)
Returns a three state toggle status of the given cell with the following consequences:
  • null - no image displayed
  • true - trueImage displayed
  • false - falseImage displayed

    Parameters:
    indexX -
    indexY -
    Returns:

  • setupSpatial

    public void setupSpatial(X indexX,
                             Y indexY)
    Overrides the default method setting the image related to toggle state.

    Overrides:
    setupSpatial in class Painter<X extends java.lang.Number,Y extends java.lang.Number>
    Parameters:
    indexX - cell index on the horizontal axis
    indexY - cell index on the vertical axis

    isOverImage

    public boolean isOverImage(int x,
                               int y)
    Returns true if coordinates are over the image of drawn by this painter, or false otherwise. It is assumed the coordinates are within the last cell the mouse was over, i.e. come from the mouse event (see Axis.getMouseItem())

    Parameters:
    x - x coordinate relative to the display
    y - y coordinate relative to the display
    Returns:
    true if coordinates are over the image of drawn by this painter


    Copyright © 2011 netanel.pl. All Rights Reserved.