Class ViewJFrameCreatePaint

All Implemented Interfaces:
ActionListener, MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class ViewJFrameCreatePaint extends JFrame implements ActionListener, MouseListener
Frame that allows the creation of custom paint brushes. Uses an array of JToggleButtons to create a grid, where the black (on) buttons represent pixels that will be "on" in the Paint Brush Bitset. Images are saved as .PNG files (tiny, generally less than 1kb) in the user_home/mipav/brushes directory (on a per-user basis). the built in brushes are stored in the view/icons directory. Saved brushes can be reloaded-overwritten within this editor as well
Author:
linkb
See Also:
  • Field Details

    • buttonGrid

      private JToggleButton[][] buttonGrid
      Array of toggle buttons used to create the grid
    • buttonSize

      private final Dimension buttonSize
      Make sure the button size is always this dimension
    • gridHeight

      private int gridHeight
      grid's height
    • gridWidth

      private int gridWidth
      grid's width
    • gridPanel

      private JPanel gridPanel
      Panel that holds the grid (stored as private variable so as to remove/rebuild the grid as needed
    • gridDialog

      The grid resize dialog
    • openItem

      private JMenu openItem
      Menu item that holds the list of paintbrushes to open (for editing)
    • blackImage

      private ImageIcon blackImage
      used to create the "selected" state of the buttons
    • whiteImage

      private ImageIcon whiteImage
      used to create the "unselected" state of the buttons
    • wasLoaded

      private boolean wasLoaded
      switch that tells the save-dialog that this brush was opened from disk, so brush will be re-written on save
    • loadName

      private String loadName
      the name of the loaded brush (used with the above wasLoaded parameter)
  • Constructor Details

    • ViewJFrameCreatePaint

      public ViewJFrameCreatePaint()
      Main constructor. Prompts user for grid size and shows the grid
  • Method Details

    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Handles action events
      Specified by:
      actionPerformed in interface ActionListener
    • openBrush

      private void openBrush(String path)
      Opens a brush stored on disk (.png)
    • populateBrushList

      private void populateBrushList()
      populates the menu item showing available brushes to edit
    • saveBrush

      private void saveBrush()
      saves the drawn paintbrush to a .png
    • init

      private void init()
    • setAllSelected

      private void setAllSelected(boolean selected)
    • mouseEntered

      public void mouseEntered(MouseEvent mouseEvent)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent mouseEvent)
      Specified by:
      mouseExited in interface MouseListener
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent mouseEvent)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent mouseEvent)
      Specified by:
      mouseReleased in interface MouseListener
    • processMouse

      private void processMouse(MouseEvent mouseEvent)
      handles the toggling function of the grid (on/off)
    • buildGrid

      private void buildGrid(BitSet preLoad)
      Builds the grid, with or without a pre-loaded BitSet (from an on-disk paintbrush)
      Parameters:
      preLoad - BitSet that can be null, if passed in then the grid will be built based on the on-disk .png file