Changeset 4480


Ignore:
Timestamp:
2003-06-04T16:18:44+12:00 (21 years ago)
Author:
mdewsnip
Message:

Added facilities for reading and writing Rectangles (for storing the Gatherer window location).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/Configuration.java

    r4363 r4480  
    243243    }
    244244
     245    /** Retrieve the value of the named property as a Rectangle. */
     246    public Rectangle getBounds(String property, boolean general) {
     247    Rectangle result = new Rectangle(100, 100, 100, 100); // Default
     248    try {
     249        String raw = getString(property, general);
     250        // Rectangle is (x, y, width, height)
     251        StringTokenizer tokenizer = new StringTokenizer(raw, TOKENIZER_PATTERN1);
     252        int x = Integer.parseInt(tokenizer.nextToken());
     253        int y = Integer.parseInt(tokenizer.nextToken());
     254        int width = Integer.parseInt(tokenizer.nextToken());
     255        int height = Integer.parseInt(tokenizer.nextToken());
     256        result = new Rectangle(x, y, width, height);
     257    }
     258    catch(Exception error) {
     259        Gatherer.printStackTrace(error);
     260    }
     261    return result;
     262    }
     263
    245264    /** Retrieve the value of the named property as a Color. */
    246265    public Color getColor(String property, boolean general) {
     
    438457    updateUI();
    439458    ///atherer.println("Collection configuration set.");
     459    }
     460
     461    /** Set the named property, from the specified configuration, using the given Rectangle value. */
     462    public void setBounds(String property, boolean general, Rectangle value) {
     463    StringBuffer text = new StringBuffer("");
     464    text.append(value.x);
     465    text.append(", ");
     466    text.append(value.y);
     467    text.append(", ");
     468    text.append(value.width);
     469    text.append(", ");
     470    text.append(value.height);
     471    setString(property, general, text.toString());
    440472    }
    441473
Note: See TracChangeset for help on using the changeset viewer.