com.cycling74.max
Class MaxBox

java.lang.Object
  extended by com.cycling74.max.MaxBox

public class MaxBox
extends java.lang.Object

MaxBox represents the graphical element of an external in a patcher. This can be used in conjunction with MaxPatcher to dynamically modify and create patchers on the fly. The interface exposed is very similar to the functionality exposed by the js javascript external and thus much of that documentation for that external is applicable well. There is no public constructor for MaxBox. MaxBoxes are created and gotten via the MaxPatcher class.

 public class maxboxtest extends MaxObject {
        
        private MaxPatcher _p = null;
        private Callback cb;
        private MaxClock cl;
        
        maxboxtest() {
                _p = this.getParentPatcher();
        
        }
        
        
  public void printboxes()
       {
           MaxBox[] boxes = _p.getAllBoxes();
           for(int i = 0; i < boxes.length; i++)
           {
              MaxBox b = boxes[i];
              post("Box "+i+": "+b.getName()+"  "+b.getMaxClass());
           } 
        }
 }
   

created on 22-Jun-2004


Constructor Summary
protected MaxBox(MaxPatcher parent, long p_box)
           
 
Method Summary
 boolean bang()
          Send this box the "bang" message.
 boolean equals(java.lang.Object o)
           
protected  void finalize()
           
 int getColorIndex()
          Gets an integer representing the color of the box.
 boolean getHidden()
           
 boolean getIgnoreClick()
           
 java.lang.String getMaxClass()
           
 java.lang.String getName()
          In a patcher box names can be set via the Max application Object menu name...
 MaxBox getNextBox()
          Gets the next box after this one in the patcher.
 MaxPatcher getPatcher()
           
protected  long getPeer()
           
 int[] getRect()
          Gets the patcher relative screen coordinates of the box.
 MaxPatcher getSubPatcher()
          Get the patcher contained within this box.
 int hashCode()
           
 void hide()
          Make this box invisible in when its parent patcher is locked.
 boolean inBackground()
           
 void inspect()
          If the object has a floating inspector this method wil luanch it.
 boolean isHighlightable()
           
 boolean isPatcher()
           
 boolean isSelected()
           
 void remove()
          Remove this box from its parent patcher.
 boolean send(float f)
          Send this box the "float" message.
 boolean send(int i)
          Send this box the "int" message.
 boolean send(java.lang.String message, Atom[] args)
          Send this box an arbitrary message.
 void setColorIndex(int color)
          Set the color of the box as an index into the color table found in the color submenu of the Max application menu.
 void setHidden(boolean b)
          Set whether or not this box will be hidden when its parent patcher is locked.
 void setIgnoreClick(boolean b)
          Set whether or not this box responds to mouse clicks.
 void setName(java.lang.String name)
          Set the name of this box.
 void setRect(int x1, int x2, int y1, int y2)
          Set the location and size of the box in patcher relative coordinates.
 void show()
          Keep this box visible in when its parent patcher is locked.
 void toBackground(boolean b)
          Set whether or not this box will be put in the background layer of its parent patcher.
 boolean understands(java.lang.String message)
          Test if a particular message is understood by this box
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MaxBox

protected MaxBox(MaxPatcher parent,
                 long p_box)
Method Detail

isPatcher

public boolean isPatcher()
Returns:
true if box is a bpatcher or subpatcher

getRect

public int[] getRect()
Gets the patcher relative screen coordinates of the box. x1,y1 is the upper left hand corner of the box and x2,y2 is the lower right hand corner.

Returns:
int array with four elements in the folowing order: x1,y1,x2,y2

getMaxClass

public java.lang.String getMaxClass()
Returns:
the name of the type of max object the box represents

getPatcher

public MaxPatcher getPatcher()
Returns:
the MaxPatcher containing this box.

getHidden

public boolean getHidden()
Returns:
true if this box is hidden on patcher lock.

getColorIndex

public int getColorIndex()
Gets an integer representing the color of the box. This int is an index into the same color table visible in the Max Object menu under the Color menu.

Returns:
the color of the box

getNextBox

public MaxBox getNextBox()
Gets the next box after this one in the patcher. This doesn't always correspond how the boxes are laid out on the screen.

Returns:
the next MaxBox in the patchers list of boxes.

isHighlightable

public boolean isHighlightable()
Returns:
true if the box can be highlighted

inBackground

public boolean inBackground()
Returns:
true if the box is part of the patcher background layer.

isSelected

public boolean isSelected()
Returns:
true if the box is currently selected.

getIgnoreClick

public boolean getIgnoreClick()
Returns:
true if the box is currently ignoring mouse clicks.

getName

public java.lang.String getName()
In a patcher box names can be set via the Max application Object menu name... item. By naming a box you can have access to it via the getNamedBox method of MaxPatcher

Returns:
the scripting name of the box

setRect

public void setRect(int x1,
                    int x2,
                    int y1,
                    int y2)
Set the location and size of the box in patcher relative coordinates.

Parameters:
x1 - upper left x
y1 - upper left y
x2 - lower right x
y2 - lower right y

setHidden

public void setHidden(boolean b)
Set whether or not this box will be hidden when its parent patcher is locked.

Parameters:
b - true to hide

setColorIndex

public void setColorIndex(int color)
Set the color of the box as an index into the color table found in the color submenu of the Max application menu.

Parameters:
color - index into the color table. This value wraps so all ints are valid.

toBackground

public void toBackground(boolean b)
Set whether or not this box will be put in the background layer of its parent patcher.

Parameters:
b - true for background

setIgnoreClick

public void setIgnoreClick(boolean b)
Set whether or not this box responds to mouse clicks.

Parameters:
b - true to ignore clicks

setName

public void setName(java.lang.String name)
Set the name of this box. This is the same as seeting the name of the box via the "name..." menu item in the Object menu of the Max application.

Parameters:
name - the scripting name of the box

bang

public boolean bang()
Send this box the "bang" message.

Returns:
true if the bang was sent successfully

send

public boolean send(int i)
Send this box the "int" message.

Parameters:
i - the int to send to this box.
Returns:
true if the int was sent successfully

send

public boolean send(float f)
Send this box the "float" message.

Parameters:
f - the float to send to this box.
Returns:
true if the float was sent successfully

send

public boolean send(java.lang.String message,
                    Atom[] args)
Send this box an arbitrary message.

Parameters:
message - the message to send to this box.
args - the arguments for the message. Can be null if the message requires no arguments.
Returns:
true if the message was sent successfully

hide

public void hide()
Make this box invisible in when its parent patcher is locked.


show

public void show()
Keep this box visible in when its parent patcher is locked.


understands

public boolean understands(java.lang.String message)
Test if a particular message is understood by this box

Parameters:
message - the message name you wish to test.
Returns:
true if this box will respond to the message

inspect

public void inspect()
If the object has a floating inspector this method wil luanch it.


remove

public void remove()
Remove this box from its parent patcher.


getSubPatcher

public MaxPatcher getSubPatcher()
Get the patcher contained within this box. This is only valid for subpatchers and bpatchers.

Returns:
the MaxPatcher represented by this box or null if this box contains no subpatcher.

getPeer

protected long getPeer()

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object