NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

RE:mouse clicking multiple cells-highlighting multiple cells

Hi Curtis,

I'm implementing the feature for a user to click on multiple cells by
holding "control" on the keyboard and clicking with the mouse. I'm using
your advice about the FancySSCell.setSelected(boolean) method called
from within SpreadSheet.selectCell(). 

I tried adding a for loop within the double for loop of SS.selectCell()
that goes through my vector holding cell choices and sets their "select"
value to true and then calls setSelected(). So I kept the original code
in the double for loop except now I'm going through each cell in the
spreadsheet with *every* iteration of the outer double for loop. This is
inefficient since I'm iterating through the vector *every* time the user
clicks on a cell and then re-highlighting all the cells that have
already been highlighted up to the new cell that the user most recently
selected. 

I thought about maybe adding a simple 1 liner to my implementation of
the DisplayListener interface in displayChanged() such as:
displayCells[ci][cj].setHighlighted(true) 
but setHighlighted is declared private in FancySSCell, and I'm not even
sure that setHighlighted() would remember the cells that are already
highlighted with each mouse click.

Do you know of a way to avoid my triple for loop in SS.selectCell() and
not re-highlight the cells that have already been highlighted with each
successive mouse click? Is there a more efficient way of handling this
case instead of my inefficient approach right now which is: 

user clicks on cell #1,
highlight cell #1,
user clicks on cell #4, 
highlight cell #1 and #4
user clicks on cell #8,
hightlight cell #1, #4, and #8

Thanks,
Michelle


Michelle Kam           (408) 742-2881
Lockheed Martin Space Systems Co. SSM/ATC/MSIS
B/153 O/L922 
1111 Lockheed Martin Way, Sunnyvale, CA 94089




-----Original Message-----
From: Curtis Rueden [mailto:curtis@xxxxxxxxxxxxx]
Sent: Tuesday, July 01, 2003 2:53 PM
To: Kam, Michelle C
Subject: RE: mouse clicking multiple cells


Hi Michelle,

SpreadSheet's top-level selectCell(int, int) method calls
FancySSCell.setSelected(boolean). With a little bit of
digging into the visad.ss source code, or even scanning the
Javadocs, you can uncover things like this yourself.

-Curtis

At 03:53 PM 7/1/2003, you wrote:
>Hi Curtis,
>
>I added a Vector to SpreadSheet.java so that when a user clicks on a
cell,
>that cell # is stored in the vector at SpreadSheet.selectCell(). I also
>implemented DisplayListener.java with my class CellDisplayListener.java
that
>checks if the mouse was clicked and "control" was held down. In that
case,
>it calls selectCell() where it updates the vector of selected cells by
>adding this one. 
>
>The cell #'s seem to be added into the vector as I click on them, but
>multiple cells cannot be highlighted at once. ie. I'll click on a cell
and
>then release the mouse to click on another cell but then the first cell
is
>no longer highlighted. Only the most recently selected cell is
highlighted.
>Is there a way to disable the de-selection of cells once the user
clicks on
>another cell? Below is CellDisplayListener.java:


  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: