KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > write > biff > SelectionRecord


1 /*********************************************************************
2 *
3 * Copyright (C) 2002 Andrew Khan
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ***************************************************************************/

19
20 package jxl.write.biff;
21
22 import jxl.biff.Type;
23 import jxl.biff.IntegerHelper;
24 import jxl.biff.WritableRecordData;
25
26 /**
27  * Stores the current selection
28  */

29 class SelectionRecord extends WritableRecordData
30 {
31   /**
32    * The pane type
33    */

34   private PaneType pane;
35   
36   /**
37    * The top left column in this pane
38    */

39   private int column;
40
41   /**
42    * The top left row in this pane
43    */

44   private int row;
45
46   // Enumeration for the pane type
47
private static class PaneType
48   {
49     int val;
50
51     PaneType(int v)
52     {val = v;}
53   }
54
55   // The pane types
56
public final static PaneType lowerRight = new PaneType(0);
57   public final static PaneType upperRight = new PaneType(1);
58   public final static PaneType lowerLeft = new PaneType(2);
59   public final static PaneType upperLeft = new PaneType(3);
60
61   /**
62    * Constructor
63    */

64   public SelectionRecord(PaneType pt, int col, int r)
65   {
66     super(Type.SELECTION);
67     column = col;
68     row = r;
69     pane = pt;
70   }
71
72   /**
73    * Gets the binary data
74    *
75    * @return the binary data
76    */

77   public byte[] getData()
78   {
79     // hard code the data in for now
80
byte[] data = new byte[15];
81     
82     data[0] = (byte) pane.val;
83     IntegerHelper.getTwoBytes(row, data, 1);
84     IntegerHelper.getTwoBytes(column, data, 3);
85
86     data[7] = (byte) 0x01;
87
88     IntegerHelper.getTwoBytes(row, data, 9);
89     IntegerHelper.getTwoBytes(row, data, 11);
90     data[13] = (byte) column;
91     data[14] = (byte) column;
92
93     return data;
94   }
95 }
96
Popular Tags