home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / prosrc.bin / CellHints.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  24.0 KB  |  736 lines

  1. /*
  2.  * Copyright (c) 1997 Krumel & Associates, Inc. All Rights Reserved.
  3.  *
  4.  * www.krumel.com - controls@krumel.com
  5.  *
  6.  * Permission is given to the buyer of this package for one software
  7.  * developer to use this software on one CPU (one workstation) and to make
  8.  * one backup copy.  You may uitilize and/or modify this class for use in your
  9.  * projects.  You may distribute or sell any executable which results from
  10.  * using this code in yur application, except a utility or class of similar
  11.  * nature to this product.  You may distribute this product in compiled
  12.  * form only, but soley to be used with your cmpiled executable product
  13.  * for the puposes of dynamic loading. You may NOT redistribute the source
  14.  * code in any form or make it accessible through a network or other
  15.  * distribution media to others. Please refer to the file "copyright.html"
  16.  * for further important copyright and licensing information.
  17.  *
  18.  * The source code is the confidential and proprietary information
  19.  * of Krumel & Associates, Inc. ("Confidential Information").  You shall
  20.  * not disclose such Confidential Information and shall use it only in
  21.  * accordance with the terms of the license agreement you entered into
  22.  * with Krumel & Associates, Inc..
  23.  
  24.  * KRUMEL & ASSOCIATES MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
  25.  * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
  26.  * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  27.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. KRUMEL & ASSOCIATES SHALL NOT
  28.  * BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
  29.  * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  30.  */
  31.  
  32. package symantec.itools.db.awt;
  33.  
  34. import java.awt.*;
  35.  
  36. /**
  37.  * CellHints specify the way a grid cell will be drawn, including things like data
  38.  * alignment within cell, font, colors, line styles, etc.
  39.  * It may apply to one or more grid cells.
  40.  */
  41. public class CellHints implements java.io.Serializable {
  42.     Rectangle   bounds = new Rectangle();
  43.     int         align;
  44.     int         valign = TableView.TOP;
  45.     boolean     editable = true;
  46.     Font        font = stdFont;
  47.     Color       fg = Color.black;
  48.     Color       bg = Color.white;
  49.     Color       hfg = Color.white;
  50.     Color       hbg = Color.blue;
  51.     boolean     highlighted = false;
  52.     int         lineTopStyle = TableView.THIN_LINE,
  53.                 lineBottomStyle = TableView.THIN_LINE,
  54.                 lineLeftStyle = TableView.THIN_LINE,
  55.                 lineRightStyle = TableView.THIN_LINE;
  56.     Color       lineTopColor = Color.gray,
  57.                 lineBottomColor = Color.gray,
  58.                 lineLeftColor = Color.gray,
  59.                 lineRightColor = Color.gray;
  60.     TableCell   defaultCell;
  61.     int         bits;
  62.     Component   control;
  63.     Object      cellStorage;
  64.  
  65.     /** Bit position constant for valid "alignment" value flag.
  66.      */
  67.     public static final int ALIGN_BIT = 0;
  68.     /** Bit position constant for valid "vertical alignment" value flag.
  69.      */
  70.     public static final int VALIGN_BIT = 1;
  71.     /** Bit position constant for valid "editable" value flag.
  72.      */
  73.     public static final int EDITABLE_BIT = 2;
  74.     /** Bit position constant for valid "font" value flag.
  75.      */
  76.     public static final int FONT_BIT = 4;
  77.     /** Bit position constant for valid "foreground color" value flag.
  78.      */
  79.     public static final int FG_BIT = 5;
  80.     /** Bit position constant for valid "background color" value flag.
  81.      */
  82.     public static final int BG_BIT = 6;
  83.     /** Bit position constant for valid "highlighted foreground color" value flag.
  84.      */
  85.     public static final int HFG_BIT = 7;
  86.     /** Bit position constant for valid "highlighted background color" value flag.
  87.      */
  88.     public static final int HBG_BIT = 8;
  89.     /** Bit position constant for valid "component" value flag.
  90.      */
  91.     public static final int CONTROL_BIT = 9;
  92.     /** Bit position constant for valid "storage object" value flag.
  93.      */
  94.     public static final int OBJECT_BIT = 10;
  95.     /** Bit position constant for valid "default table cell" value flag.
  96.      */
  97.     public static final int DEFAULT_BIT = 11;
  98.     /** Bit position constant for valid "top boundry line style" value flag.
  99.      */
  100.     public static final int LINE_TOP_STYLE_BIT = 12;
  101.     /** Bit position constant for valid "left boundry line style" value flag.
  102.      */
  103.     public static final int LINE_LEFT_STYLE_BIT = 13;
  104.     /** Bit position constant for valid "bottom boundry line style" value flag.
  105.      */
  106.     public static final int LINE_BOTTOM_STYLE_BIT = 14;
  107.     /** Bit position constant for valid "right boundry line style" value flag.
  108.      */
  109.     public static final int LINE_RIGHT_STYLE_BIT = 15;
  110.     /** Bit position constant for valid "top boundry line color" value flag.
  111.      */
  112.     public static final int LINE_TOP_COLOR_BIT = 16;
  113.     /** Bit position constant for valid "left boundry line color" value flag.
  114.      */
  115.     public static final int LINE_LEFT_COLOR_BIT = 17;
  116.     /** Bit position constant for valid "bottom boundry line color" value flag.
  117.      */
  118.     public static final int LINE_BOTTOM_COLOR_BIT = 18;
  119.     /** Bit position constant for valid "right boundry line color" value flag.
  120.      */
  121.     public static final int LINE_RIGHT_COLOR_BIT = 19;
  122.  
  123.     /** The standard cell font.
  124.      */
  125.     public static Font stdFont = new Font("Dialog", Font.PLAIN, 12);
  126.     TableView   view;
  127.     TableCell   cell;
  128.  
  129.     /**
  130.      * Constructs a new CellHints object for cells in the given TableView.
  131.      * @param v the TableView
  132.      */
  133.     public CellHints(TableView v) {
  134.         view = v;
  135.     }
  136.  
  137.     /**
  138.      * Sets the sepecified flag bit.
  139.      * @param bit the zero-relative bit index
  140.      */
  141.     public void set(int bit) {
  142.         bits |= (1<<bit);
  143.     }
  144.  
  145.     /**
  146.      * Clears the sepecified flag bit.
  147.      * @param bit the zero-relative bit index
  148.      */
  149.     public void clear(int bit) {
  150.         bits &= ~(1L << bit);
  151.     }
  152.  
  153.     /**
  154.      * Gets the sepecified flag bit.
  155.      * @param bit the zero-relative bit index
  156.      * @return the value of the bit
  157.      */
  158.     public boolean get(int bit) {
  159.         return ((bits >> bit) & 1) != 0;
  160.     }
  161.  
  162.     /**
  163.      * Sets the given Graphics object's clipping rectangle
  164.      * to the value indicated by this CellHint.
  165.      * @param g the Graphics context
  166.      */
  167.     public void clip(Graphics g) {
  168.         g.clipRect(bounds.x, bounds.y, bounds.width, bounds.height);
  169.     }
  170.  
  171.     /**
  172.      * Sets the given Graphics object's foreground color
  173.      * to the value indicated by this CellHint.
  174.      * @param g the Graphics context
  175.      */
  176.     public void setForeground(Graphics g) {
  177.         if (highlighted) {
  178.             g.setColor(hfg);
  179.         } else {
  180.             g.setColor(fg);
  181.         }
  182.     }
  183.  
  184.     /**
  185.      * Sets the given Graphics object's background color
  186.      * to the value indicated by this CellHint.
  187.      * @param g the Graphics context
  188.      */
  189.     public void setBackground(Graphics g) {
  190.         if (highlighted) {
  191.             g.setColor(hbg);
  192.         } else {
  193.            g.setColor(bg);
  194.         }
  195.     }
  196.  
  197.     /**
  198.      * Initializes this CellHint for the given TableCell.
  199.      * @param c the TableCell this CellHint is for
  200.      */
  201.     public final void setHints(TableCell c) {
  202.         cell = c;
  203.  
  204.         if (cell.type() == TableCell.CORNER_CELL) {
  205.             setCornerCellHints(c);
  206.             return;
  207.         }
  208.  
  209.         bounds = view.getCellBounds(c, bounds);
  210.         align = view.getCellAlignment(c);
  211.         fg = view.getCellFG(c);
  212.         bg = view.getCellBG(c);
  213.         editable = view.getCellEditable(c);
  214.         highlighted = view.getCellHighlighted(c);
  215.         font = view.getCellFont(c);
  216.         cellStorage = view.getCellStorage(c);
  217.         control = view.getCellControl(c);
  218.         view.putLineStyles(cell, this);
  219.     }
  220.  
  221.     void setCornerCellHints(TableCell c) {
  222.         CellHints rowHints = view.rowHeadingHints;
  223.  
  224.         bounds = view.getCellBounds(c, bounds);
  225.         align = rowHints.align;
  226.         fg = rowHints.fg;
  227.         bg = rowHints.bg;
  228.         editable = rowHints.editable;
  229.         highlighted = view.isViewSelected();
  230.         font = rowHints.font;
  231.     }
  232.  
  233.     //-------------------------------------------------------------------------
  234.     //      Line styles and line color APIs
  235.     //-------------------------------------------------------------------------
  236.  
  237.     void setTopLineStyle(int style) {
  238.         set(LINE_TOP_STYLE_BIT);
  239.         lineTopStyle = style;
  240.     }
  241.  
  242.     void clearTopLineStyle() { clear(LINE_TOP_STYLE_BIT); }
  243.  
  244.     void setTopLineColor(Color c) {
  245.         set(LINE_TOP_COLOR_BIT);
  246.         lineTopColor = c;
  247.     }
  248.  
  249.     void clearTopLineColor() { clear(LINE_TOP_COLOR_BIT); }
  250.  
  251.     void setLeftLineStyle(int style) {
  252.         set(LINE_LEFT_STYLE_BIT);
  253.         lineLeftStyle = style;
  254.     }
  255.  
  256.     void clearLeftLineStyle() { clear(LINE_LEFT_STYLE_BIT); }
  257.  
  258.     void setLeftLineColor(Color c) {
  259.         set(LINE_LEFT_COLOR_BIT);
  260.         lineLeftColor = c;
  261.     }
  262.  
  263.     void clearLeftLineColor() { clear(LINE_BOTTOM_COLOR_BIT); }
  264.  
  265.     void setBottomLineStyle(int style) {
  266.         set(LINE_BOTTOM_STYLE_BIT);
  267.         lineBottomStyle = style;
  268.     }
  269.  
  270.     void clearBottomLineStyle() { clear(LINE_BOTTOM_STYLE_BIT); }
  271.  
  272.     void setBottomLineColor(Color c) {
  273.         set(LINE_BOTTOM_COLOR_BIT);
  274.         lineBottomColor = c;
  275.     }
  276.  
  277.     void clearBottomLineColor() { clear(LINE_BOTTOM_COLOR_BIT); }
  278.  
  279.     void setRightLineStyle(int style) {
  280.         set(LINE_RIGHT_STYLE_BIT);
  281.         lineRightStyle = style;
  282.     }
  283.  
  284.     void clearRightLineStyle() { clear(LINE_RIGHT_STYLE_BIT); }
  285.  
  286.     void setRightLineColor(Color c) {
  287.         set(LINE_RIGHT_COLOR_BIT);
  288.         lineRightColor = c;
  289.     }
  290.  
  291.     void clearRightLineColor() { clear(LINE_RIGHT_COLOR_BIT); }
  292.  
  293.     final void cascadeLineStyles(CellHints row, CellHints cell, CellHints col) {
  294.         //cascade styles
  295.         lineTopStyle = cascadeInt(LINE_TOP_STYLE_BIT, row, cell,
  296.                                     row!=null ?row.lineTopStyle :-1,
  297.                                     cell!=null ?cell.lineTopStyle :-1,
  298.                                     col.lineTopStyle);
  299.         lineLeftStyle = cascadeInt(LINE_LEFT_STYLE_BIT, row, cell,
  300.                                     row!=null ?row.lineLeftStyle :-1,
  301.                                     cell!=null ?cell.lineLeftStyle :-1,
  302.                                     col.lineLeftStyle);
  303.         lineBottomStyle = cascadeInt(LINE_BOTTOM_STYLE_BIT, row, cell,
  304.                                     row!=null ?row.lineBottomStyle :-1,
  305.                                     cell!=null ?cell.lineBottomStyle :-1,
  306.                                     col.lineBottomStyle);
  307.         lineRightStyle = cascadeInt(LINE_RIGHT_STYLE_BIT, row, cell,
  308.                                     row!=null ?row.lineRightStyle :-1,
  309.                                     cell!=null ?cell.lineRightStyle :-1,
  310.                                     col.lineRightStyle);
  311.  
  312.         //cascade colors
  313.         lineTopColor = cascadeColor(LINE_TOP_COLOR_BIT, row, cell,
  314.                                     row!=null ?row.lineTopColor :null,
  315.                                     cell!=null ?cell.lineTopColor :null,
  316.                                     col.lineTopColor);
  317.         lineLeftColor = cascadeColor(LINE_LEFT_COLOR_BIT, row, cell,
  318.                                     row!=null ?row.lineLeftColor :null,
  319.                                     cell!=null ?cell.lineLeftColor :null,
  320.                                     col.lineLeftColor);
  321.         lineBottomColor = cascadeColor(LINE_BOTTOM_COLOR_BIT, row, cell,
  322.                                     row!=null ?row.lineBottomColor :null,
  323.                                     cell!=null ?cell.lineBottomColor :null,
  324.                                     col.lineBottomColor);
  325.         lineRightColor = cascadeColor(LINE_RIGHT_COLOR_BIT, row, cell,
  326.                                     row!=null ?row.lineRightColor :null,
  327.                                     cell!=null ?cell.lineRightColor :null,
  328.                                     col.lineRightColor);
  329.     }
  330.  
  331.     final int cascadeInt(int bit, CellHints row, CellHints cell, int v1, int v2, int vme) {
  332.         if (cell!=null && cell.get(bit)) {
  333.             return v2;
  334.         } else if (row!=null && row.get(bit)) {
  335.             return v1;
  336.         }
  337.  
  338.         return vme;
  339.     }
  340.  
  341.     final Color cascadeColor(int bit, CellHints row, CellHints cell, Color v1, Color v2, Color vme) {
  342.         if (cell!=null && cell.get(bit)) {
  343.             return v2;
  344.         } else if (row!=null && row.get(bit)) {
  345.             return v1;
  346.         }
  347.  
  348.         return vme;
  349.     }
  350.  
  351.     /**
  352.      * Draws the cell boundy indicated by this CellHint.
  353.      * @param g the Graphics context used for drawing
  354.      */
  355.     public final void drawBoundary(Graphics g) {
  356.         Rectangle r = bounds;
  357.         if (lineTopStyle != TableView.NO_LINE) {
  358.             g.setColor(lineTopColor);
  359.             g.drawLine(r.x, r.y, r.x+r.width-1, r.y);
  360.  
  361.             if (lineTopStyle == TableView.THICK_LINE) {
  362.                 g.drawLine(r.x, r.y+1, r.x+r.width-1, r.y+1);
  363.             }
  364.         }
  365.         if (lineBottomStyle != TableView.NO_LINE) {
  366.             g.setColor(lineBottomColor);
  367.             g.drawLine(r.x, r.y+r.height-1, r.x+r.width-1, r.y+r.height-1);
  368.              if (lineBottomStyle == TableView.THICK_LINE) {
  369.                 g.drawLine(r.x, r.y+r.height-2, r.x+r.width-1, r.y+r.height-2);
  370.             }
  371.         }
  372.  
  373.         if (lineLeftStyle != TableView.NO_LINE) {
  374.             g.setColor(lineLeftColor);
  375.             g.drawLine(r.x, r.y, r.x, r.y+r.height-1);
  376.              if (lineLeftStyle == TableView.THICK_LINE) {
  377.                 g.drawLine(r.x+1, r.y, r.x+1, r.y+r.height-1);
  378.             }
  379.        }
  380.         if (lineRightStyle != TableView.NO_LINE) {
  381.             g.setColor(lineRightColor);
  382.             g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1, r.y+r.height-1);
  383.              if (lineRightStyle == TableView.THICK_LINE) {
  384.                 g.drawLine(r.x+r.width-2, r.y, r.x+r.width-2, r.y+r.height-1);
  385.             }
  386.         }
  387.     }
  388.  
  389.     /**
  390.      * Gets the cell bounds indicated by this CellHint.
  391.      * @return the cell's bounding rectangle
  392.      */
  393.     public final Rectangle bounds() { return bounds; }
  394.  
  395.     /**
  396.      * Gets this CellHint's "horizontal alignment" value.
  397.      * @return the cell's alignment, one of TableView.LEFT,
  398.      * TableView.CENTER, or TableView.RIGHT
  399.      */
  400.     public final int alignment() { return align; }
  401.  
  402.     /**
  403.      * Gets a valid horizontal alignment value.
  404.      * This method first checks c2, then c1, and then this CellHint.
  405.      * @return the cell's alignment, one of TableView.LEFT,
  406.      * TableView.CENTER, or TableView.RIGHT
  407.      */
  408.     public final int cascadeAlignment(CellHints c1, CellHints c2) {
  409.         if (c2 != null && c2.get(ALIGN_BIT)) {
  410.             return c2.align;
  411.         } else if (c1 != null && c1.get(ALIGN_BIT)) {
  412.             return c1.align;
  413.         }
  414.  
  415.         return align;
  416.     }
  417.  
  418.     /**
  419.      * Gets this CellHint's "editable" value.
  420.      * @return the value
  421.      */
  422.     public final boolean editable() { return editable; }
  423.  
  424.     /**
  425.      * Gets a valid "editable" value.
  426.      * This method first checks c2, then c1, and then this CellHint.
  427.      * @return the value
  428.      */
  429.     public final boolean cascadeEditable(CellHints c1, CellHints c2) {
  430.         if (c2 != null && c2.get(EDITABLE_BIT)) {
  431.             return c2.editable;
  432.         } else if (c1 != null && c1.get(EDITABLE_BIT)) {
  433.             return c1.editable;
  434.         }
  435.  
  436.         return editable;
  437.     }
  438.  
  439.     /**
  440.      * Gets this CellHint's "vertical alignment" value.
  441.      * @return the cell's alignment, one of TableView.TOP,
  442.      * TableView.CENTER, or TableView.BOTTOM
  443.      */
  444.     public final int vAlignment() { return valign; }
  445.  
  446.     /**
  447.      * Gets a valid vertical alignment value.
  448.      * This method first checks c2, then c1, and then this CellHint.
  449.      * @return the cell's alignment, one of TableView.TOP,
  450.      * TableView.CENTER, or TableView.BOTTOM
  451.      */
  452.     public final int cascadeVAlignment(CellHints c1, CellHints c2) {
  453.         if (c2 != null && c2.get(VALIGN_BIT)) {
  454.             return c2.valign;
  455.         } else if (c1 != null && c1.get(VALIGN_BIT)) {
  456.             return c1.valign;
  457.         }
  458.  
  459.         return valign;
  460.     }
  461.  
  462.     /**
  463.      * Gets this CellHint's "font" value.
  464.      * @return the value
  465.      */
  466.     public final Font font() { return font; }
  467.  
  468.     /**
  469.      * Gets a valid "font" value.
  470.      * This method first checks c2, then c1, and then this CellHint.
  471.      * @return the value
  472.      */
  473.     public final Font cascadeFont(CellHints c1, CellHints c2) {
  474.         if (c2 != null && c2.get(FONT_BIT)) {
  475.             return c2.font;
  476.         } else if (c1 != null && c1.get(FONT_BIT)) {
  477.             return c1.font;
  478.         }
  479.  
  480.         return font;
  481.     }
  482.  
  483.     /**
  484.      * Gets this CellHint's "foreground color" value.
  485.      * @return the value
  486.      */
  487.     public final Color foreground() { return fg; }
  488.  
  489.     /**
  490.      * Gets a valid "foreground color" value.
  491.      * This method first checks c2, then c1, and then this CellHint.
  492.      * @return the value
  493.      */
  494.     public final Color cascadeForeground(CellHints c1, CellHints c2) {
  495.         if (c2 != null && c2.get(FG_BIT)) {
  496.             return c2.fg;
  497.         } else if (c1 != null && c1.get(FG_BIT)) {
  498.             return c1.fg;
  499.         }
  500.  
  501.         return fg;
  502.     }
  503.  
  504.     /**
  505.      * Gets this CellHint's "background color" value.
  506.      * @return the value
  507.      */
  508.     public final Color background() { return bg; }
  509.  
  510.     /**
  511.      * Gets a valid "background color" value.
  512.      * This method first checks c2, then c1, and then this CellHint.
  513.      * @return the value
  514.      */
  515.     public final Color cascadeBackground(CellHints c1, CellHints c2) {
  516.         if (c2 != null && c2.get(BG_BIT)) {
  517.             return c2.bg;
  518.         } else if (c1 != null && c1.get(BG_BIT)) {
  519.             return c1.bg;
  520.         }
  521.  
  522.         return bg;
  523.     }
  524.  
  525.     /**
  526.      * Gets this CellHint's "highlighted" value.
  527.      * @return <code>true</code> if highlited, <code>false</code>otherwise
  528.      */
  529.     public final boolean highlighted() { return highlighted; }
  530.  
  531.     /**
  532.      * Gets this CellHint's "hilighted foreground color" value.
  533.      * @return the value
  534.      */
  535.     public final Color hlForeground() { return hfg; }
  536.  
  537.     /**
  538.      * Gets a valid "hilighted foreground color" value.
  539.      * This method first checks c2, then c1, and then this CellHint.
  540.      * @return the value
  541.      */
  542.     public final Color cascadeHlForeground(CellHints c1, CellHints c2) {
  543.         if (c2 != null && c2.get(HFG_BIT)) {
  544.             return c2.hfg;
  545.         } else if (c1 != null && c1.get(HFG_BIT)) {
  546.             return c1.hfg;
  547.         }
  548.  
  549.         return hfg;
  550.     }
  551.  
  552.     /**
  553.      * Gets this CellHint's "hilighted background color" value.
  554.      * @return the value
  555.      */
  556.     public final Color hlBackground() { return hbg; }
  557.  
  558.     /**
  559.      * Gets a valid "hilighted background color" value.
  560.      * This method first checks c2, then c1, and then this CellHint.
  561.      * @return the value
  562.      */
  563.     public final Color cascadeHlBackground(CellHints c1, CellHints c2) {
  564.         if (c2 != null && c2.get(HBG_BIT)) {
  565.             return c2.hbg;
  566.         } else if (c1 != null && c1.get(HBG_BIT)) {
  567.             return c1.hbg;
  568.         }
  569.  
  570.         return hbg;
  571.     }
  572.  
  573.     /**
  574.      * Gets this CellHint's "top line of boundy" color value.
  575.      * @return the value
  576.      */
  577.     public final Color lineTopColor() { return lineTopColor; }
  578.  
  579.     /**
  580.      * Gets this CellHint's "bottom line of boundy" color value.
  581.      * @return the value
  582.      */
  583.     public final Color lineBottomColor() { return lineBottomColor; }
  584.  
  585.     /**
  586.      * Gets this CellHint's "left line of boundy" color value.
  587.      * @return the value
  588.      */
  589.     public final Color lineLeftColor() { return lineLeftColor; }
  590.  
  591.     /**
  592.      * Gets this CellHint's "right line of boundy" color value.
  593.      * @return the value
  594.      */
  595.     public final Color lineRightColor() { return lineRightColor; }
  596.  
  597.     /**
  598.      * Gets this CellHint's "top line style of boundy" color value.
  599.      * @return the value,
  600.      * one of TableView.NO_LINE, TableView.THIN_LINE, or TableView.THICK_LINE
  601.      */
  602.     public final int lineTopStyle() { return lineTopStyle; }
  603.  
  604.     /**
  605.      * Gets this CellHint's "bottom line style of boundy" color value.
  606.      * @return the value,
  607.      * one of TableView.NO_LINE, TableView.THIN_LINE, or TableView.THICK_LINE
  608.      */
  609.     public final int lineBottomStyle() { return lineBottomStyle; }
  610.  
  611.     /**
  612.      * Gets this CellHint's "left line style of boundy" color value.
  613.      * @return the value,
  614.      * one of TableView.NO_LINE, TableView.THIN_LINE, or TableView.THICK_LINE
  615.      */
  616.     public final int lineLeftStyle() { return lineLeftStyle; }
  617.  
  618.     /**
  619.      * Gets this CellHint's "right line style of boundy" color value.
  620.      * @return the value,
  621.      * one of TableView.NO_LINE, TableView.THIN_LINE, or TableView.THICK_LINE
  622.      */
  623.     public final int lineRightStyle() { return lineRightStyle; }
  624.  
  625.     /**
  626.      * Gets the component in this cell.
  627.      * @return the component
  628.      * @see #setControl
  629.      */
  630.     public Object control() { return control; }
  631.  
  632.     /**
  633.      * Sets the component in this cell.
  634.      * @param c the component
  635.      * @see #control
  636.      */
  637.     protected final void setControl(Component c) {
  638.         control = c;
  639.         if (cell != null) {
  640.             set(CONTROL_BIT);
  641.         } else {
  642.             clear(CONTROL_BIT);
  643.         }
  644.     }
  645.  
  646.     /**
  647.      * Gets a valid cell component.
  648.      * This method first checks c2, then c1, and then this CellHint.
  649.      * @return the component
  650.      */
  651.     public Component cascadeControl(CellHints c1, CellHints c2) {
  652.         if (c2 != null && c2.get(CONTROL_BIT)) {
  653.             return c2.control;
  654.         } else if (c1 != null && c1.get(CONTROL_BIT)) {
  655.             return c1.control;
  656.         }
  657.  
  658.         return control;
  659.     }
  660.  
  661.     /**
  662.      * Sets the object stored in this CellHint.
  663.      * @param o the object
  664.      * @see #cellStorage
  665.      */
  666.     protected void setCellStorage(Object o) {
  667.         cellStorage = o;
  668.         if (cell != null) {
  669.             set(OBJECT_BIT);
  670.         } else {
  671.             clear(OBJECT_BIT);
  672.         }
  673.     }
  674.  
  675.     /**
  676.      * Gets the object stored in this CellHint.
  677.      * @return the object
  678.      * @see #setCellStorage
  679.      */
  680.     public Object cellStorage() { return cellStorage; }
  681.  
  682.     /**
  683.      * Gets a valid CellHint stored object.
  684.      * This method first checks c2, then c1, and then this CellHint.
  685.      * @return the stored object
  686.      */
  687.     public Object cascadeStorage(CellHints c1, CellHints c2) {
  688.         if (c2 != null && c2.get(OBJECT_BIT)) {
  689.             return c2.cellStorage;
  690.         } else if (c1 != null && c1.get(OBJECT_BIT)) {
  691.             return c1.cellStorage;
  692.         }
  693.  
  694.         return cellStorage;
  695.     }
  696.  
  697.     /**
  698.      * Sets the default table cell for this CellHint.
  699.      * @param cell the default cell
  700.      * @see #defaultCell
  701.      */
  702.     protected void setDefaultCell(TableCell cell) {
  703.         defaultCell = cell;
  704.         setControl(cell.auxControl());
  705.  
  706.         if (cell != null) {
  707.             set(DEFAULT_BIT);
  708.         } else {
  709.             clear(DEFAULT_BIT);
  710.         }
  711.     }
  712.  
  713.     /**
  714.      * Gets the default table cell for this CellHint.
  715.      * @return the table cell
  716.      * @see #setDefaultCell
  717.      */
  718.     public final TableCell defaultCell() { return defaultCell; }
  719.  
  720.     /**
  721.      * Gets a valid CellHint default table cell.
  722.      * This method first checks c2, then c1, and then this CellHint.
  723.      * @return the default table cell
  724.      */
  725.     public final TableCell cascadeDefaultCell(CellHints c1, CellHints c2) {
  726.         if (c2 != null && c2.get(DEFAULT_BIT)) {
  727.             return c2.defaultCell;
  728.         } else if (c1 != null && c1.get(DEFAULT_BIT)) {
  729.             return c1.defaultCell;
  730.         }
  731.  
  732.         return defaultCell;
  733.     }
  734.  
  735. }
  736.