aboutsummaryrefslogtreecommitdiffstats
path: root/src/examples
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2019-12-09 20:56:52 +0000
committerAndreas Beeker <kiwiwings@apache.org>2019-12-09 20:56:52 +0000
commit4c4a33c5de1380533790182ef8a38509e5fa4b70 (patch)
tree6a0a7cc976009096e188f899d5a9389b60b0fc76 /src/examples
parentd8bfbaffdf680f8272407356b2506aed369c6dc8 (diff)
downloadpoi-4c4a33c5de1380533790182ef8a38509e5fa4b70.tar.gz
poi-4c4a33c5de1380533790182ef8a38509e5fa4b70.zip
Remove POIBrowser and SViewer and remove references to it
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1871102 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/SVBorder.java559
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/SVFractionalFormat.java229
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/SVRowHeader.java109
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java261
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java215
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java286
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/SVTableModel.java97
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/SVTableUtils.java94
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/SViewer.java197
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/SViewerPanel.java343
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/brush/BasicBrush.java72
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/brush/Brush.java31
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/brush/DoubleStroke.java64
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/brush/PendingPaintings.java178
-rw-r--r--src/examples/src/org/apache/poi/hssf/view/brush/package-info.java21
-rw-r--r--src/examples/src/org/apache/poi/poifs/poibrowser/DocumentDescriptor.java77
-rw-r--r--src/examples/src/org/apache/poi/poifs/poibrowser/DocumentDescriptorRenderer.java72
-rw-r--r--src/examples/src/org/apache/poi/poifs/poibrowser/ExtendableTreeCellRenderer.java144
-rw-r--r--src/examples/src/org/apache/poi/poifs/poibrowser/POIBrowser.java119
-rw-r--r--src/examples/src/org/apache/poi/poifs/poibrowser/PropertySetDescriptor.java75
-rw-r--r--src/examples/src/org/apache/poi/poifs/poibrowser/PropertySetDescriptorRenderer.java170
-rw-r--r--src/examples/src/org/apache/poi/poifs/poibrowser/TreeReaderListener.java215
-rw-r--r--src/examples/src/org/apache/poi/poifs/poibrowser/Util.java41
23 files changed, 0 insertions, 3669 deletions
diff --git a/src/examples/src/org/apache/poi/hssf/view/SVBorder.java b/src/examples/src/org/apache/poi/hssf/view/SVBorder.java
deleted file mode 100644
index dd0fe35d73..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/SVBorder.java
+++ /dev/null
@@ -1,559 +0,0 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hssf.view;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Graphics;
-
-import javax.swing.border.AbstractBorder;
-
-import org.apache.poi.ss.usermodel.BorderStyle;
-
-/**
- * This is an attempt to implement Excel style borders for the SheetViewer.
- * Mostly just overrides stuff so the javadoc won't appear here but will
- * appear in the generated stuff.
- *
- * @author Andrew C. Oliver (acoliver at apache dot org)
- * @author Jason Height
- */
-public class SVBorder extends AbstractBorder {
- private Color northColor;
- private Color eastColor;
- private Color southColor;
- private Color westColor;
- private BorderStyle northBorderType = BorderStyle.NONE;
- private BorderStyle eastBorderType = BorderStyle.NONE;
- private BorderStyle southBorderType = BorderStyle.NONE;
- private BorderStyle westBorderType = BorderStyle.NONE;
- private boolean northBorder;
- private boolean eastBorder;
- private boolean southBorder;
- private boolean westBorder;
- private boolean selected;
-
- public void setBorder(Color northColor, Color eastColor,
- Color southColor, Color westColor,
- BorderStyle northBorderType, BorderStyle eastBorderType,
- BorderStyle southBorderType, BorderStyle westBorderType,
- boolean selected) {
- this.eastColor = eastColor;
- this.southColor = southColor;
- this.westColor = westColor;
- this.northBorderType = northBorderType;
- this.eastBorderType = eastBorderType;
- this.southBorderType = southBorderType;
- this.westBorderType = westBorderType;
- this.northBorder = northBorderType != BorderStyle.NONE;
- this.eastBorder = eastBorderType != BorderStyle.NONE;
- this.southBorder = southBorderType != BorderStyle.NONE;
- this.westBorder = westBorderType != BorderStyle.NONE;
- this.selected = selected;
- }
-
- @Override
- public void paintBorder(Component c, Graphics g, int x, int y, int width,
- int height) {
- Color oldColor = g.getColor();
-
-
- paintSelectedBorder(g, x, y, width, height);
- paintNormalBorders(g, x, y, width, height);
- paintDottedBorders(g, x, y, width, height);
- paintDashedBorders(g, x, y, width, height);
- paintDoubleBorders(g, x, y, width, height);
- paintDashDotDotBorders(g, x, y, width, height);
-
-
- g.setColor(oldColor);
- }
-
- /**
- * Called by paintBorder to paint the border of a selected cell.
- * The paramaters are the Graphics object, location and dimensions of the
- * cell.
- */
- private void paintSelectedBorder(Graphics g, int x, int y, int width,
- int height) {
- if (selected) {
- //Need to setup thickness of 2
- g.setColor(Color.black);
- //paint the border
- g.drawRect(x, y, width - 1, height - 1);
-
- //paint the filled rectangle at the bottom left hand position
- g.fillRect(x + width - 5, y + height - 5, 5, 5);
- }
- }
-
-
- /**
- * Called by paintBorder to paint the various versions of normal line
- * borders for a cell.
- */
- private void paintNormalBorders(Graphics g, int x, int y, int width,
- int height) {
-
- if (northBorder &&
- ((northBorderType == BorderStyle.THIN) ||
- (northBorderType == BorderStyle.MEDIUM) ||
- (northBorderType == BorderStyle.THICK)
- )
- ) {
-
- int thickness = getThickness(northBorderType);
-
- g.setColor(northColor);
-
- for (int k = 0; k < thickness; k++) {
- g.drawLine(x, y + k, width, y + k);
- }
- }
-
- if (eastBorder &&
- ((eastBorderType == BorderStyle.THIN) ||
- (eastBorderType == BorderStyle.MEDIUM) ||
- (eastBorderType == BorderStyle.THICK)
- )
- ) {
-
- int thickness = getThickness(eastBorderType);
-
- g.setColor(eastColor);
-
- for (int k = 0; k < thickness; k++) {
- g.drawLine(width - k, y, width - k, height);
- }
- }
-
- if (southBorder &&
- ((southBorderType == BorderStyle.THIN) ||
- (southBorderType == BorderStyle.MEDIUM) ||
- (southBorderType == BorderStyle.THICK)
- )
- ) {
-
- int thickness = getThickness(southBorderType);
-
- g.setColor(southColor);
- for (int k = 0; k < thickness; k++) {
- g.drawLine(x, height - k, width, height - k);
- }
- }
-
- if (westBorder &&
- ((westBorderType == BorderStyle.THIN) ||
- (westBorderType == BorderStyle.MEDIUM) ||
- (westBorderType == BorderStyle.THICK)
- )
- ) {
-
- int thickness = getThickness(westBorderType);
-
- g.setColor(westColor);
-
- for (int k = 0; k < thickness; k++) {
- g.drawLine(x + k, y, x + k, height);
- }
- }
- }
-
- /**
- * Called by paintBorder to paint the dotted line
- * borders for a cell.
- */
- private void paintDottedBorders(Graphics g, int x, int y, int width,
- int height) {
- if (northBorder &&
- northBorderType == BorderStyle.DOTTED) {
- int thickness = getThickness(northBorderType);
-
- g.setColor(northColor);
-
- for (int k = 0; k < thickness; k++) {
- for (int xc = x; xc < width; xc = xc + 2) {
- g.drawLine(xc, y + k, xc, y + k);
- }
- }
- }
-
- if (eastBorder &&
- eastBorderType == BorderStyle.DOTTED
- ) {
-
- int thickness = getThickness(eastBorderType);
- thickness++; //need for dotted borders to show up east
-
- g.setColor(eastColor);
-
- for (int k = 0; k < thickness; k++) {
- for (int yc = y; yc < height; yc = yc + 2) {
- g.drawLine(width - k, yc, width - k, yc);
- }
- }
- }
-
- if (southBorder &&
- southBorderType == BorderStyle.DOTTED
- ) {
-
- int thickness = getThickness(southBorderType);
- thickness++;
- g.setColor(southColor);
- for (int k = 0; k < thickness; k++) {
- for (int xc = x; xc < width; xc = xc + 2) {
- g.drawLine(xc, height - k, xc, height - k);
- }
- }
- }
-
- if (westBorder &&
- westBorderType == BorderStyle.DOTTED
- ) {
-
- int thickness = getThickness(westBorderType);
-// thickness++;
-
- g.setColor(westColor);
-
- for (int k = 0; k < thickness; k++) {
- for (int yc = y; yc < height; yc = yc + 2) {
- g.drawLine(x + k, yc, x + k, yc);
- }
- }
- }
- }
-
- /**
- * Called by paintBorder to paint the various versions of dotted line
- * borders for a cell.
- */
- private void paintDashedBorders(Graphics g, int x, int y, int width,
- int height) {
- if (northBorder &&
- ((northBorderType == BorderStyle.DASHED) ||
- (northBorderType == BorderStyle.HAIR))
- ) {
- int thickness = getThickness(northBorderType);
-
- int dashlength = 1;
-
- if (northBorderType == BorderStyle.DASHED)
- dashlength = 2;
-
- g.setColor(northColor);
-
- for (int k = 0; k < thickness; k++) {
- for (int xc = x; xc < width; xc = xc + 5) {
- g.drawLine(xc, y + k, xc + dashlength, y + k);
- }
- }
- }
-
- if (eastBorder &&
- ((eastBorderType == BorderStyle.DASHED) ||
- (eastBorderType == BorderStyle.HAIR))
- ) {
-
- int thickness = getThickness(eastBorderType);
- thickness++; //need for dotted borders to show up east
-
-
- int dashlength = 1;
-
- if (eastBorderType == BorderStyle.DASHED)
- dashlength = 2;
-
- g.setColor(eastColor);
-
- for (int k = 0; k < thickness; k++) {
- for (int yc = y; yc < height; yc = yc + 5) {
- g.drawLine(width - k, yc, width - k, yc + dashlength);
- }
- }
- }
-
- if (southBorder &&
- ((southBorderType == BorderStyle.DASHED) ||
- (southBorderType == BorderStyle.HAIR))
- ) {
-
- int thickness = getThickness(southBorderType);
- thickness++;
-
- int dashlength = 1;
-
- if (southBorderType == BorderStyle.DASHED)
- dashlength = 2;
-
- g.setColor(southColor);
- for (int k = 0; k < thickness; k++) {
- for (int xc = x; xc < width; xc = xc + 5) {
- g.drawLine(xc, height - k, xc + dashlength, height - k);
- }
- }
- }
-
- if (westBorder &&
- ((westBorderType == BorderStyle.DASHED) ||
- (westBorderType == BorderStyle.HAIR))
- ) {
-
- int thickness = getThickness(westBorderType);
-// thickness++;
-
- int dashlength = 1;
-
- if (westBorderType == BorderStyle.DASHED)
- dashlength = 2;
-
- g.setColor(westColor);
-
- for (int k = 0; k < thickness; k++) {
- for (int yc = y; yc < height; yc = yc + 5) {
- g.drawLine(x + k, yc, x + k, yc + dashlength);
- }
- }
- }
- }
-
- /**
- * Called by paintBorder to paint the double line
- * borders for a cell.
- */
- private void paintDoubleBorders(Graphics g, int x, int y, int width,
- int height) {
- if (northBorder &&
- northBorderType == BorderStyle.DOUBLE) {
-
- g.setColor(northColor);
-
- int leftx = x;
- int rightx = width;
-
- // if there are borders on the west or east then
- // the second line shouldn't cross them
- if (westBorder) {
- leftx = x + 3;
- }
-
- if (eastBorder) {
- rightx = width - 3;
- }
-
- g.drawLine(x, y, width, y);
- g.drawLine(leftx, y + 2, rightx, y + 2);
- }
-
- if (eastBorder &&
- eastBorderType == BorderStyle.DOUBLE
- ) {
-
- int thickness = getThickness(eastBorderType);
- thickness++; //need for dotted borders to show up east
-
- g.setColor(eastColor);
-
- int topy = y;
- int bottomy = height;
-
- if (northBorder) {
- topy = y + 3;
- }
-
- if (southBorder) {
- bottomy = height - 3;
- }
-
- g.drawLine(width - 1, y, width - 1, height);
- g.drawLine(width - 3, topy, width - 3, bottomy);
- }
-
- if (southBorder &&
- southBorderType == BorderStyle.DOUBLE
- ) {
-
- g.setColor(southColor);
-
- int leftx = y;
- int rightx = width;
-
- if (westBorder)
- leftx = x + 3;
-
- if (eastBorder)
- rightx = width - 3;
-
-
- g.drawLine(x, height - 1, width, height - 1);
- g.drawLine(leftx, height - 3, rightx, height - 3);
- }
-
- if (westBorder &&
- westBorderType == BorderStyle.DOUBLE
- ) {
-
- int thickness = getThickness(westBorderType);
-// thickness++;
-
- g.setColor(westColor);
-
- int topy = y;
- int bottomy = height - 3;
-
- if (northBorder)
- topy = y + 2;
-
- if (southBorder)
- bottomy = height - 3;
-
- g.drawLine(x, y, x, height);
- g.drawLine(x + 2, topy, x + 2, bottomy);
- }
- }
-
- /**
- * Called by paintBorder to paint the various versions of dash dot dot line
- * borders for a cell.
- */
- private void paintDashDotDotBorders(Graphics g, int x, int y, int width,
- int height) {
- if (northBorder &&
- ((northBorderType == BorderStyle.DASH_DOT_DOT) ||
- (northBorderType == BorderStyle.MEDIUM_DASH_DOT_DOT))
- ) {
- int thickness = getThickness(northBorderType);
-
- g.setColor(northColor);
- for (int l = x; l < width; ) {
- l = l + drawDashDotDot(g, l, y, thickness, true, true);
- }
-
- }
-
- if (eastBorder &&
- ((eastBorderType == BorderStyle.DASH_DOT_DOT) ||
- (eastBorderType == BorderStyle.MEDIUM_DASH_DOT_DOT))
- ) {
-
- int thickness = getThickness(eastBorderType);
-
- g.setColor(eastColor);
-
- for (int l = y; l < height; ) {
- //System.err.println("drawing east");
- l = l + drawDashDotDot(g, width - 1, l, thickness, false, false);
- }
- }
-
- if (southBorder &&
- ((southBorderType == BorderStyle.DASH_DOT_DOT) ||
- (southBorderType == BorderStyle.MEDIUM_DASH_DOT_DOT))
- ) {
-
- int thickness = getThickness(southBorderType);
-
- g.setColor(southColor);
-
- for (int l = x; l < width; ) {
- //System.err.println("drawing south");
- l = l + drawDashDotDot(g, l, height - 1, thickness, true, false);
- }
- }
-
- if (westBorder &&
- ((westBorderType == BorderStyle.DASH_DOT_DOT) ||
- (westBorderType == BorderStyle.MEDIUM_DASH_DOT_DOT))
- ) {
-
- int thickness = getThickness(westBorderType);
-
- g.setColor(westColor);
-
- for (int l = y; l < height; ) {
- //System.err.println("drawing west");
- l = l + drawDashDotDot(g, x, l, thickness, false, true);
- }
-
- }
- }
-
- /**
- * Draws one dash dot dot horizontally or vertically with thickness drawn
- * incrementally to either the right or left.
- *
- * @param g graphics object for drawing with
- * @param x the x origin of the line
- * @param y the y origin of the line
- * @param thickness the thickness of the line
- * @param horizontal or vertical (true for horizontal)
- * @param rightBottom or left/top thickness (true for right or top),
- * if true then the x or y origin will be incremented to provide
- * thickness, if false, they'll be decremented. For vertical
- * borders, x is incremented or decremented, for horizontal its y.
- * Just set to true for north and west, and false for east and
- * south.
- * @return length - returns the length of the line.
- */
- private int drawDashDotDot(Graphics g, int x, int y, int thickness,
- boolean horizontal,
- boolean rightBottom) {
-
- for (int t = 0; t < thickness; t++) {
- if (!rightBottom) {
- t = 0 - t; //add negative thickness so we go the other way
- //then we'll decrement instead of increment.
- }
- if (horizontal) {
- g.drawLine(x, y + t, x + 5, y + t);
- g.drawLine(x + 8, y + t, x + 10, y + t);
- g.drawLine(x + 13, y + t, x + 15, y + t);
- } else {
- g.drawLine(x + t, y, x + t, y + 5);
- g.drawLine(x + t, y + 8, x + t, y + 10);
- g.drawLine(x + t, y + 13, x + t, y + 15);
- }
- }
- return 18;
- }
-
- /**
- * @return the line thickness for a border based on border type
- */
- private int getThickness(BorderStyle thickness) {
- switch (thickness) {
- case DASH_DOT_DOT:
- case DASHED:
- case HAIR:
- return 1;
- case THIN:
- return 2;
- case MEDIUM:
- case MEDIUM_DASH_DOT_DOT:
- return 3;
- case THICK:
- return 4;
- default:
- return 1;
- }
- }
-
-
-}
diff --git a/src/examples/src/org/apache/poi/hssf/view/SVFractionalFormat.java b/src/examples/src/org/apache/poi/hssf/view/SVFractionalFormat.java
deleted file mode 100644
index 9f2d1a2b52..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/SVFractionalFormat.java
+++ /dev/null
@@ -1,229 +0,0 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-
-package org.apache.poi.hssf.view;
-
-import java.text.FieldPosition;
-import java.text.Format;
-import java.text.ParseException;
-import java.text.ParsePosition;
-
-/**
- * This class is used to format cells into their fractional format.
- * <p>
- * I cant be 100% sure that the same fractional value will be displayed as in
- * excel but then again it is a lossy formating mode anyway
- *
- * @author Jason Height
- * @since 15 July 2002
- */
-public class SVFractionalFormat extends Format {
- private short ONE_DIGIT = 1;
- private short TWO_DIGIT = 2;
- private short THREE_DIGIT = 3;
- private short UNITS = 4;
- private int units = 1;
- private short mode = -1;
-
- /**
- * Constructs a new FractionalFormatter
- * <p>
- * The formatStr defines how the number will be formatted
- * # ?/? Up to one digit
- * # ??/?? Up to two digits
- * # ???/??? Up to three digits
- * # ?/2 In halves
- * # ?/4 In quarters
- * # ?/8 In eighths
- * # ?/16 In sixteenths
- * # ?/10 In tenths
- * # ?/100 In hundredths
- */
- public SVFractionalFormat(String formatStr) {
- if ("# ?/?".equals(formatStr))
- mode = ONE_DIGIT;
- else if ("# ??/??".equals(formatStr))
- mode = TWO_DIGIT;
- else if ("# ???/???".equals(formatStr))
- mode = THREE_DIGIT;
- else if ("# ?/2".equals(formatStr)) {
- mode = UNITS;
- units = 2;
- } else if ("# ?/4".equals(formatStr)) {
- mode = UNITS;
- units = 4;
- } else if ("# ?/8".equals(formatStr)) {
- mode = UNITS;
- units = 8;
- } else if ("# ?/16".equals(formatStr)) {
- mode = UNITS;
- units = 16;
- } else if ("# ?/10".equals(formatStr)) {
- mode = UNITS;
- units = 10;
- } else if ("# ?/100".equals(formatStr)) {
- mode = UNITS;
- units = 100;
- }
- }
-
- /**
- * Returns a fractional string representation of a double to a maximum denominator size
- * <p>
- * This code has been translated to java from the following web page.
- * http://www.codeproject.com/cpp/fraction.asp
- * Originally coded in c++ By Dean Wyant dwyant@mindspring.com
- * The code on the web page is freely available.
- *
- * @param f Description of the Parameter
- * @param MaxDen Description of the Parameter
- * @return Description of the Return Value
- */
- private String format(final double f, final int MaxDen) {
- long Whole = (long) f;
- int sign = 1;
- if (f < 0) {
- sign = -1;
- }
- double Precision = 0.00001;
- double AllowedError = Precision;
- double d = Math.abs(f);
- d -= Whole;
- double Frac = d;
- double Diff = Frac;
- long Num = 1;
- long Den = 0;
- long A = 0;
- long B = 0;
- long i = 0;
- if (Frac > Precision) {
- while (true) {
- d = 1.0 / d;
- i = (long) (d + Precision);
- d -= i;
- if (A > 0) {
- Num = i * Num + B;
- }
- Den = (long) (Num / Frac + 0.5);
- Diff = Math.abs((double) Num / Den - Frac);
- if (Den > MaxDen) {
- if (A > 0) {
- Num = A;
- Den = (long) (Num / Frac + 0.5);
- Diff = Math.abs((double) Num / Den - Frac);
- } else {
- Den = MaxDen;
- Num = 1;
- Diff = Math.abs((double) Num / Den - Frac);
- if (Diff > Frac) {
- Num = 0;
- Den = 1;
- // Keeps final check below from adding 1 and keeps Den from being 0
- Diff = Frac;
- }
- }
- break;
- }
- if ((Diff <= AllowedError) || (d < Precision)) {
- break;
- }
- Precision = AllowedError / Diff;
- // This calculation of Precision does not always provide results within
- // Allowed Error. It compensates for loss of significant digits that occurs.
- // It helps to round the imprecise reciprocal values to i.
- B = A;
- A = Num;
- }
- }
- if (Num == Den) {
- Whole++;
- Num = 0;
- Den = 0;
- } else if (Den == 0) {
- Num = 0;
- }
- if (sign < 0) {
- if (Whole == 0) {
- Num = -Num;
- } else {
- Whole = -Whole;
- }
- }
- return new StringBuilder().append(Whole).append(" ").append(Num).append("/").append(Den).toString();
- }
-
- /**
- * This method formats the double in the units specified.
- * The usints could be any number but in this current implementation it is
- * halves (2), quaters (4), eigths (8) etc
- */
- private String formatUnit(double f, int units) {
- long Whole = (long) f;
- f -= Whole;
- long Num = Math.round(f * units);
-
- return new StringBuilder().append(Whole).append(" ").append(Num).append("/").append(units).toString();
- }
-
- public final String format(double val) {
- if (mode == ONE_DIGIT) {
- return format(val, 9);
- } else if (mode == TWO_DIGIT) {
- return format(val, 99);
- } else if (mode == THREE_DIGIT) {
- return format(val, 999);
- } else if (mode == UNITS) {
- return formatUnit(val, units);
- }
- throw new RuntimeException("Unexpected Case");
- }
-
- @Override
- public StringBuffer format(Object obj,
- StringBuffer toAppendTo,
- FieldPosition pos) {
- if (obj instanceof Number) {
- toAppendTo.append(format(((Number) obj).doubleValue()));
- return toAppendTo;
- }
- throw new IllegalArgumentException("Can only handle Numbers");
- }
-
- @Override
- public Object parseObject(String source,
- ParsePosition status) {
- //JMH TBD
- return null;
- }
-
- @Override
- public Object parseObject(String source)
- throws ParseException {
- //JMH TBD
- return null;
- }
-
- @Override
- public Object clone() {
- //JMH TBD
- return null;
- }
-
-
-}
diff --git a/src/examples/src/org/apache/poi/hssf/view/SVRowHeader.java b/src/examples/src/org/apache/poi/hssf/view/SVRowHeader.java
deleted file mode 100644
index 834d0a0068..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/SVRowHeader.java
+++ /dev/null
@@ -1,109 +0,0 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-
-package org.apache.poi.hssf.view;
-
-import java.awt.Component;
-import java.awt.Dimension;
-
-import javax.swing.AbstractListModel;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JTable;
-import javax.swing.ListCellRenderer;
-import javax.swing.ListModel;
-import javax.swing.UIManager;
-import javax.swing.table.JTableHeader;
-
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-
-/**
- * This class presents the row header to the table.
- *
- * @author Jason Height
- */
-public class SVRowHeader extends JList<Object> {
- /**
- * This model simply returns an integer number up to the number of rows
- * that are present in the sheet.
- */
- private class SVRowHeaderModel extends AbstractListModel<Object> {
- private HSSFSheet sheet;
-
- public SVRowHeaderModel(HSSFSheet sheet) {
- this.sheet = sheet;
- }
-
- @Override
- public int getSize() {
- return sheet.getLastRowNum() + 1;
- }
-
- @Override
- public Object getElementAt(int index) {
- return Integer.toString(index + 1);
- }
- }
-
- /**
- * Renderes the row number
- */
- private class RowHeaderRenderer extends JLabel implements ListCellRenderer<Object> {
- private HSSFSheet sheet;
- private int extraHeight;
-
- RowHeaderRenderer(HSSFSheet sheet, JTable table, int extraHeight) {
- this.sheet = sheet;
- this.extraHeight = extraHeight;
- JTableHeader header = table.getTableHeader();
- setOpaque(true);
- setBorder(UIManager.getBorder("TableHeader.cellBorder"));
- setHorizontalAlignment(CENTER);
- setForeground(header.getForeground());
- setBackground(header.getBackground());
- setFont(header.getFont());
- }
-
- @Override
- public Component getListCellRendererComponent(JList list,
- Object value, int index, boolean isSelected, boolean cellHasFocus) {
- Dimension d = getPreferredSize();
- HSSFRow row = sheet.getRow(index);
- int rowHeight;
- if (row == null) {
- rowHeight = (int) sheet.getDefaultRowHeightInPoints();
- } else {
- rowHeight = (int) row.getHeightInPoints();
- }
- d.height = rowHeight + extraHeight;
- setPreferredSize(d);
- setText((value == null) ? "" : value.toString());
- return this;
- }
- }
-
- public SVRowHeader(HSSFSheet sheet, JTable table, int extraHeight) {
- ListModel<Object> lm = new SVRowHeaderModel(sheet);
- this.setModel(lm);
-
- setFixedCellWidth(50);
- setCellRenderer(new RowHeaderRenderer(sheet, table, extraHeight));
- }
-}
diff --git a/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java b/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java
deleted file mode 100644
index 7c41cad868..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hssf.view;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.Toolkit;
-import java.awt.event.HierarchyEvent;
-import java.awt.event.HierarchyListener;
-
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JViewport;
-import javax.swing.ListSelectionModel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.table.JTableHeader;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableColumnModel;
-import javax.swing.table.TableModel;
-import javax.swing.text.JTextComponent;
-
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.view.brush.PendingPaintings;
-import org.apache.poi.ss.usermodel.CellType;
-import org.apache.poi.ss.usermodel.Row;
-
-/**
- * This class is a table that represents the values in a single worksheet.
- *
- * @author Ken Arnold, Industrious Media LLC
- */
-public class SVSheetTable extends JTable {
- private final HSSFSheet sheet;
- private final PendingPaintings pendingPaintings;
- private FormulaDisplayListener formulaListener;
- private JScrollPane scroll;
-
- private static final Color HEADER_BACKGROUND = new Color(235, 235, 235);
-
- /**
- * This field is the magic number to convert from a Character width to a java
- * pixel width.
- * <p>
- * When the "normal" font size in a workbook changes, this effects all of the
- * heights and widths. Unfortunately there is no way to retrieve this
- * information, hence the MAGIC number.
- * <p>
- * This number may only work for the normal style font size of Arial size 10.
- */
- private static final int magicCharFactor = 7;
-
- private class HeaderCell extends JLabel {
- private final int row;
-
- public HeaderCell(Object value, int row) {
- super(value.toString(), CENTER);
- this.row = row;
- setBackground(HEADER_BACKGROUND);
- setOpaque(true);
- setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
- setRowSelectionAllowed(false);
- }
-
- @Override
- public Dimension getPreferredSize() {
- Dimension d = super.getPreferredSize();
- if (row >= 0) {
- d.height = getRowHeight(row);
- }
- return d;
- }
-
- @Override
- public Dimension getMaximumSize() {
- Dimension d = super.getMaximumSize();
- if (row >= 0) {
- d.height = getRowHeight(row);
- }
- return d;
- }
-
- @Override
- public Dimension getMinimumSize() {
- Dimension d = super.getMinimumSize();
- if (row >= 0) {
- d.height = getRowHeight(row);
- }
- return d;
- }
- }
-
- private class HeaderCellRenderer implements TableCellRenderer {
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected, boolean hasFocus, int row, int column) {
-
- return new HeaderCell(value, row);
- }
- }
-
- private class FormulaDisplayListener implements ListSelectionListener {
- private final JTextComponent formulaDisplay;
-
- public FormulaDisplayListener(JTextComponent formulaDisplay) {
- this.formulaDisplay = formulaDisplay;
- }
-
- @Override
- public void valueChanged(ListSelectionEvent e) {
- int row = getSelectedRow();
- int col = getSelectedColumn();
- if (row < 0 || col < 0) {
- return;
- }
-
- if (e.getValueIsAdjusting()) {
- return;
- }
-
- HSSFCell cell = (HSSFCell) getValueAt(row, col);
- String formula = "";
- if (cell != null) {
- if (cell.getCellType() == CellType.FORMULA) {
- formula = cell.getCellFormula();
- } else {
- formula = cell.toString();
- }
- if (formula == null)
- formula = "";
- }
- formulaDisplay.setText(formula);
- }
- }
-
- public SVSheetTable(HSSFSheet sheet) {
- super(new SVTableModel(sheet));
- this.sheet = sheet;
-
- setIntercellSpacing(new Dimension(0, 0));
- setAutoResizeMode(AUTO_RESIZE_OFF);
- JTableHeader header = getTableHeader();
- header.setDefaultRenderer(new HeaderCellRenderer());
- pendingPaintings = new PendingPaintings(this);
-
- //Set the columns the correct size
- TableColumnModel columns = getColumnModel();
- for (int i = 0; i < columns.getColumnCount(); i++) {
- TableColumn column = columns.getColumn(i);
- int width = sheet.getColumnWidth(i);
- //256 is because the width is in 256ths of a character
- column.setPreferredWidth(width / 256 * magicCharFactor);
- }
-
- Toolkit t = getToolkit();
- int res = t.getScreenResolution();
- TableModel model = getModel();
- for (int i = 0; i < model.getRowCount(); i++) {
- Row row = sheet.getRow(i - sheet.getFirstRowNum());
- if (row != null) {
- short h = row.getHeight();
- int height = Math.toIntExact(Math.round(Math.max(1., h / (res / 70. * 20.) + 3.)));
- System.out.printf("%d: %d (%d @ %d)%n", i, height, h, res);
- setRowHeight(i, height);
- }
- }
-
- addHierarchyListener(new HierarchyListener() {
- @Override
- public void hierarchyChanged(HierarchyEvent e) {
- if ((e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) != 0) {
- Container changedParent = e.getChangedParent();
- if (changedParent instanceof JViewport) {
- Container grandparent = changedParent.getParent();
- if (grandparent instanceof JScrollPane) {
- JScrollPane jScrollPane = (JScrollPane) grandparent;
- setupScroll(jScrollPane);
- }
- }
- }
- }
- });
- }
-
- public void setupScroll(JScrollPane scroll) {
- if (scroll == this.scroll)
- return;
-
- this.scroll = scroll;
- if (scroll == null)
- return;
-
- SVRowHeader rowHeader = new SVRowHeader(sheet, this, 0);
- scroll.setRowHeaderView(rowHeader);
- scroll.setCorner(JScrollPane.UPPER_LEADING_CORNER, headerCell("?"));
- }
-
- public void setFormulaDisplay(JTextComponent formulaDisplay) {
- ListSelectionModel rowSelMod = getSelectionModel();
- ListSelectionModel colSelMod = getColumnModel().getSelectionModel();
-
- if (formulaDisplay == null) {
- rowSelMod.removeListSelectionListener(formulaListener);
- colSelMod.removeListSelectionListener(formulaListener);
- formulaListener = null;
- }
-
- if (formulaDisplay != null) {
- formulaListener = new FormulaDisplayListener(formulaDisplay);
- rowSelMod.addListSelectionListener(formulaListener);
- colSelMod.addListSelectionListener(formulaListener);
- }
- }
-
- public JTextComponent getFormulaDisplay() {
- if (formulaListener == null)
- return null;
- else
- return formulaListener.formulaDisplay;
- }
-
- public Component headerCell(String text) {
- return new HeaderCell(text, -1);
- }
-
- @Override
- public void paintComponent(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
-
- pendingPaintings.clear();
-
- g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- super.paintComponent(g);
-
- pendingPaintings.paint(g);
- }
-} \ No newline at end of file
diff --git a/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java b/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java
deleted file mode 100644
index 484df3b9e4..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java
+++ /dev/null
@@ -1,215 +0,0 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hssf.view;
-
-import static org.apache.poi.hssf.view.SVTableUtils.getAWTColor;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseEvent;
-import java.util.EventObject;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.SwingConstants;
-import javax.swing.table.TableCellEditor;
-
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFCellStyle;
-import org.apache.poi.hssf.usermodel.HSSFFont;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
-import org.apache.poi.ss.usermodel.FillPatternType;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
-
-/**
- * Sheet Viewer Table Cell Editor -- not commented via javadoc as it
- * nearly completely consists of overridden methods.
- *
- * @author Jason Height
- */
-public class SVTableCellEditor extends AbstractCellEditor implements TableCellEditor, ActionListener {
- private static final Color black = getAWTColor(HSSFColorPredefined.BLACK);
- private static final Color white = getAWTColor(HSSFColorPredefined.WHITE);
- private static final POILogger logger = POILogFactory.getLogger(SVTableCellEditor.class);
-
- private HSSFWorkbook wb;
- private JTextField editor;
-
- public SVTableCellEditor(HSSFWorkbook wb) {
- this.wb = wb;
- this.editor = new JTextField();
- }
-
-
- /**
- * Gets the cellEditable attribute of the SVTableCellEditor object
- *
- * @return The cellEditable value
- */
- @Override
- public boolean isCellEditable(java.util.EventObject e) {
- if (e instanceof MouseEvent) {
- return ((MouseEvent) e).getClickCount() >= 2;
- }
- return false;
- }
-
-
- @Override
- public boolean shouldSelectCell(EventObject anEvent) {
- return true;
- }
-
-
- public boolean startCellEditing(EventObject anEvent) {
- logger.log(POILogger.INFO, "Start Cell Editing");
- return true;
- }
-
-
- @Override
- public boolean stopCellEditing() {
- logger.log(POILogger.INFO, "Stop Cell Editing");
- fireEditingStopped();
- return true;
- }
-
-
- @Override
- public void cancelCellEditing() {
- logger.log(POILogger.INFO, "Cancel Cell Editing");
- fireEditingCanceled();
- }
-
-
- @Override
- public void actionPerformed(ActionEvent e) {
- logger.log(POILogger.INFO, "Action performed");
- stopCellEditing();
- }
-
-
- /**
- * Gets the cellEditorValue attribute of the SVTableCellEditor object
- *
- * @return The cellEditorValue value
- */
- @Override
- public Object getCellEditorValue() {
- logger.log(POILogger.INFO, "GetCellEditorValue");
- //JMH Look at when this method is called. Should it return a HSSFCell?
- return editor.getText();
- }
-
-
- /**
- * Gets the tableCellEditorComponent attribute of the SVTableCellEditor object
- *
- * @return The tableCellEditorComponent value
- */
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value,
- boolean isSelected,
- int row,
- int column) {
- logger.log(POILogger.INFO, "GetTableCellEditorComponent");
- HSSFCell cell = (HSSFCell) value;
- if (cell != null) {
- HSSFCellStyle style = cell.getCellStyle();
- HSSFFont f = wb.getFontAt(style.getFontIndexAsInt());
- boolean isbold = f.getBold();
- boolean isitalics = f.getItalic();
-
- int fontstyle = Font.PLAIN;
-
- if (isbold) {
- fontstyle = Font.BOLD;
- }
- if (isitalics) {
- fontstyle = fontstyle | Font.ITALIC;
- }
-
- int fontheight = f.getFontHeightInPoints();
- if (fontheight == 9) {
- fontheight = 10; //fix for stupid ol Windows
- }
-
- Font font = new Font(f.getFontName(), fontstyle, fontheight);
- editor.setFont(font);
-
- if (style.getFillPattern() == FillPatternType.SOLID_FOREGROUND) {
- editor.setBackground(getAWTColor(style.getFillForegroundColor(), white));
- } else {
- editor.setBackground(white);
- }
-
- editor.setForeground(getAWTColor(f.getColor(), black));
-
-
- //Set the value that is rendered for the cell
- switch (cell.getCellType()) {
- case BLANK:
- editor.setText("");
- break;
- case BOOLEAN:
- if (cell.getBooleanCellValue()) {
- editor.setText("true");
- } else {
- editor.setText("false");
- }
- break;
- case NUMERIC:
- editor.setText(Double.toString(cell.getNumericCellValue()));
- break;
- case STRING:
- editor.setText(cell.getRichStringCellValue().getString());
- break;
- case FORMULA:
- default:
- editor.setText("?");
- }
- switch (style.getAlignment()) {
- case LEFT:
- case JUSTIFY:
- case FILL:
- editor.setHorizontalAlignment(SwingConstants.LEFT);
- break;
- case CENTER:
- case CENTER_SELECTION:
- editor.setHorizontalAlignment(SwingConstants.CENTER);
- break;
- case GENERAL:
- case RIGHT:
- editor.setHorizontalAlignment(SwingConstants.RIGHT);
- break;
- default:
- editor.setHorizontalAlignment(SwingConstants.LEFT);
- break;
- }
-
- }
- return editor;
- }
-}
diff --git a/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java b/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java
deleted file mode 100644
index 04351e35f8..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java
+++ /dev/null
@@ -1,286 +0,0 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-
-package org.apache.poi.hssf.view;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Rectangle;
-import java.io.Serializable;
-import java.text.DecimalFormat;
-import java.text.Format;
-import java.text.SimpleDateFormat;
-
-import javax.swing.JLabel;
-import javax.swing.JTable;
-import javax.swing.SwingConstants;
-import javax.swing.UIManager;
-import javax.swing.border.Border;
-import javax.swing.border.EmptyBorder;
-import javax.swing.table.TableCellRenderer;
-
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFCellStyle;
-import org.apache.poi.hssf.usermodel.HSSFFont;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.BorderStyle;
-import org.apache.poi.ss.usermodel.FillPatternType;
-
-
-/**
- * Sheet Viewer Table Cell Render -- not commented via javadoc as it
- * nearly completely consists of overridden methods.
- *
- * @author Andrew C. Oliver
- */
-public class SVTableCellRenderer extends JLabel
- implements TableCellRenderer, Serializable {
- protected static final Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
- protected SVBorder cellBorder = new SVBorder();
-
- private HSSFWorkbook wb;
-
- /**
- * This class holds the references to the predefined cell formats.
- */
- private class CellFormatter {
- private Format[] textFormatter;
-
- private DecimalFormat generalNumberFormat = new DecimalFormat("0");
-
- public CellFormatter() {
- textFormatter = new Format[0x31];
-
- textFormatter[0x01] = new DecimalFormat("0");
- textFormatter[0x02] = new DecimalFormat("0.00");
- textFormatter[0x03] = new DecimalFormat("#,##0");
- textFormatter[0x04] = new DecimalFormat("#,##0.00");
- textFormatter[0x05] = new DecimalFormat("$#,##0;$#,##0");
- textFormatter[0x06] = new DecimalFormat("$#,##0;$#,##0");
- textFormatter[0x07] = new DecimalFormat("$#,##0.00;$#,##0.00");
- textFormatter[0x08] = new DecimalFormat("$#,##0.00;$#,##0.00");
- textFormatter[0x09] = new DecimalFormat("0%");
- textFormatter[0x0A] = new DecimalFormat("0.00%");
- textFormatter[0x0B] = new DecimalFormat("0.00E0");
- textFormatter[0x0C] = new SVFractionalFormat("# ?/?");
- textFormatter[0x0D] = new SVFractionalFormat("# ??/??");
- textFormatter[0x0E] = new SimpleDateFormat("M/d/yy");
- textFormatter[0x0F] = new SimpleDateFormat("d-MMM-yy");
- textFormatter[0x10] = new SimpleDateFormat("d-MMM");
- textFormatter[0x11] = new SimpleDateFormat("MMM-yy");
- textFormatter[0x12] = new SimpleDateFormat("h:mm a");
- textFormatter[0x13] = new SimpleDateFormat("h:mm:ss a");
- textFormatter[0x14] = new SimpleDateFormat("h:mm");
- textFormatter[0x15] = new SimpleDateFormat("h:mm:ss");
- textFormatter[0x16] = new SimpleDateFormat("M/d/yy h:mm");
- // 0x17 - 0x24 reserved for international and undocumented 0x25, "(#,##0_);(#,##0)"
- //start at 0x26
- //jmh need to do colour
- //"(#,##0_);[Red](#,##0)"
- textFormatter[0x26] = new DecimalFormat("#,##0;#,##0");
- //jmh need to do colour
- //(#,##0.00_);(#,##0.00)
- textFormatter[0x27] = new DecimalFormat("#,##0.00;#,##0.00");
- textFormatter[0x28] = new DecimalFormat("#,##0.00;#,##0.00");
-//?? textFormatter[0x29] = new DecimalFormat("_(*#,##0_);_(*(#,##0);_(* \"-\"_);_(@_)");
-//?? textFormatter[0x2A] = new DecimalFormat("_($*#,##0_);_($*(#,##0);_($* \"-\"_);_(@_)");
-//?? textFormatter[0x2B] = new DecimalFormat("_(*#,##0.00_);_(*(#,##0.00);_(*\"-\"??_);_(@_)");
-//?? textFormatter[0x2C] = new DecimalFormat("_($*#,##0.00_);_($*(#,##0.00);_($*\"-\"??_);_(@_)");
- textFormatter[0x2D] = new SimpleDateFormat("mm:ss");
-//?? textFormatter[0x2E] = new SimpleDateFormat("[h]:mm:ss");
- textFormatter[0x2F] = new SimpleDateFormat("mm:ss.0");
- textFormatter[0x30] = new DecimalFormat("##0.0E0");
- }
-
- public String format(short index, double value) {
- if (index <= 0)
- return generalNumberFormat.format(value);
- if (textFormatter[index] == null)
- throw new RuntimeException("Sorry. I cant handle the format code :" + Integer.toHexString(index));
- if (textFormatter[index] instanceof DecimalFormat) {
- return ((DecimalFormat) textFormatter[index]).format(value);
- }
- if (textFormatter[index] instanceof SVFractionalFormat) {
- return ((SVFractionalFormat) textFormatter[index]).format(value);
- }
- throw new RuntimeException("Sorry. I cant handle a non decimal formatter for a decimal value :" + Integer.toHexString(index));
- }
-
- public boolean useRedColor(short index, double value) {
- return (((index == 0x06) || (index == 0x08) || (index == 0x26) || (index == 0x27)) && (value < 0));
- }
- }
-
- private final CellFormatter cellFormatter = new CellFormatter();
-
- public SVTableCellRenderer(HSSFWorkbook wb) {
- super();
- setOpaque(true);
- setBorder(noFocusBorder);
- this.wb = wb;
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected, boolean hasFocus, int row, int column) {
- boolean isBorderSet = false;
-
- //If the JTables default cell renderer has been setup correctly the
- //value will be the HSSFCell that we are trying to render
- HSSFCell c = (HSSFCell) value;
-
- if (c != null) {
- HSSFCellStyle s = c.getCellStyle();
- HSSFFont f = wb.getFontAt(s.getFontIndexAsInt());
- setFont(SVTableUtils.makeFont(f));
-
- if (s.getFillPattern() == FillPatternType.SOLID_FOREGROUND) {
- setBackground(SVTableUtils.getAWTColor(s.getFillForegroundColor(), SVTableUtils.white));
- } else setBackground(SVTableUtils.white);
-
- setForeground(SVTableUtils.getAWTColor(f.getColor(), SVTableUtils.black));
-
- cellBorder.setBorder(SVTableUtils.getAWTColor(s.getTopBorderColor(), SVTableUtils.black),
- SVTableUtils.getAWTColor(s.getRightBorderColor(), SVTableUtils.black),
- SVTableUtils.getAWTColor(s.getBottomBorderColor(), SVTableUtils.black),
- SVTableUtils.getAWTColor(s.getLeftBorderColor(), SVTableUtils.black),
- s.getBorderTop(), s.getBorderRight(),
- s.getBorderBottom(), s.getBorderLeft(),
- hasFocus);
- setBorder(cellBorder);
- isBorderSet = true;
-
- //Set the value that is rendered for the cell
- switch (c.getCellType()) {
- case BLANK:
- setValue("");
- break;
- case BOOLEAN:
- if (c.getBooleanCellValue()) {
- setValue("true");
- } else {
- setValue("false");
- }
- break;
- case NUMERIC:
- short format = s.getDataFormat();
- double numericValue = c.getNumericCellValue();
- if (cellFormatter.useRedColor(format, numericValue))
- setForeground(Color.red);
- else setForeground(null);
- setValue(cellFormatter.format(format, c.getNumericCellValue()));
- break;
- case STRING:
- setValue(c.getRichStringCellValue().getString());
- break;
- case FORMULA:
- default:
- setValue("?");
- }
- //Set the text alignment of the cell
- switch (s.getAlignment()) {
- case LEFT:
- case JUSTIFY:
- case FILL:
- setHorizontalAlignment(SwingConstants.LEFT);
- break;
- case CENTER:
- case CENTER_SELECTION:
- setHorizontalAlignment(SwingConstants.CENTER);
- break;
- case GENERAL:
- case RIGHT:
- setHorizontalAlignment(SwingConstants.RIGHT);
- break;
- default:
- setHorizontalAlignment(SwingConstants.LEFT);
- break;
- }
- } else {
- setValue("");
- setBackground(SVTableUtils.white);
- }
-
-
- if (hasFocus) {
- if (!isBorderSet) {
- //This is the border to paint when there is no border
- //and the cell has focus
- cellBorder.setBorder(SVTableUtils.black,
- SVTableUtils.black,
- SVTableUtils.black,
- SVTableUtils.black,
- BorderStyle.NONE,
- BorderStyle.NONE,
- BorderStyle.NONE,
- BorderStyle.NONE,
- isSelected);
- setBorder(cellBorder);
- }
- if (table.isCellEditable(row, column)) {
- setForeground(UIManager.getColor("Table.focusCellForeground"));
- setBackground(UIManager.getColor("Table.focusCellBackground"));
- }
- } else if (!isBorderSet) {
- setBorder(noFocusBorder);
- }
-
- // ---- begin optimization to avoid painting background ----
- Color back = getBackground();
- boolean colorMatch = (back != null) && (back.equals(table.getBackground())) && table.isOpaque();
- setOpaque(!colorMatch);
- // ---- end optimization to aviod painting background ----
- return this;
- }
-
- @Override
- public void validate() {
- }
-
- @Override
- public void revalidate() {
- }
-
- @Override
- public void repaint(long tm, int x, int y, int width, int height) {
- }
-
- @Override
- public void repaint(Rectangle r) {
- }
-
- @Override
- protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
- // Strings get interned...
- if (propertyName == "text") {
- super.firePropertyChange(propertyName, oldValue, newValue);
- }
- }
-
- @Override
- public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {
- }
-
- /**
- * Sets the string to either the value or "" if the value is null.
- */
- protected void setValue(Object value) {
- setText((value == null) ? "" : value.toString());
- }
-}
diff --git a/src/examples/src/org/apache/poi/hssf/view/SVTableModel.java b/src/examples/src/org/apache/poi/hssf/view/SVTableModel.java
deleted file mode 100644
index 14c06a70bd..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/SVTableModel.java
+++ /dev/null
@@ -1,97 +0,0 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-
-package org.apache.poi.hssf.view;
-
-import java.util.Iterator;
-
-import javax.swing.table.AbstractTableModel;
-
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.ss.usermodel.Row;
-
-/**
- * Sheet Viewer Table Model - The model for the Sheet Viewer just overrides things.
- *
- * @author Andrew C. Oliver
- */
-
-public class SVTableModel extends AbstractTableModel {
- private HSSFSheet st;
- int maxcol;
-
- public SVTableModel(HSSFSheet st, int maxcol) {
- this.st = st;
- this.maxcol = maxcol;
- }
-
- public SVTableModel(HSSFSheet st) {
- this.st = st;
- Iterator<Row> i = st.rowIterator();
-
- while (i.hasNext()) {
- HSSFRow row = (HSSFRow) i.next();
- if (maxcol < (row.getLastCellNum() + 1)) {
- this.maxcol = row.getLastCellNum();
- }
- }
- }
-
-
- @Override
- public int getColumnCount() {
- return this.maxcol + 1;
- }
-
- @Override
- public Object getValueAt(int row, int col) {
- HSSFRow r = st.getRow(row);
- HSSFCell c = null;
- if (r != null) {
- c = r.getCell(col);
- }
- return c;
- }
-
- @Override
- public int getRowCount() {
- return st.getLastRowNum() + 1;
- }
-
- @Override
- public Class<?> getColumnClass(int c) {
- return HSSFCell.class;
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return true;
- }
-
- @Override
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
- if (aValue != null)
- System.out.println("SVTableModel.setValueAt. value type = " + aValue.getClass().getName());
- else System.out.println("SVTableModel.setValueAt. value type = null");
- }
-
-
-}
diff --git a/src/examples/src/org/apache/poi/hssf/view/SVTableUtils.java b/src/examples/src/org/apache/poi/hssf/view/SVTableUtils.java
deleted file mode 100644
index 57ba3956fe..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/SVTableUtils.java
+++ /dev/null
@@ -1,94 +0,0 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hssf.view;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.util.Map;
-
-import javax.swing.border.Border;
-import javax.swing.border.EmptyBorder;
-
-import org.apache.poi.hssf.usermodel.HSSFFont;
-import org.apache.poi.hssf.util.HSSFColor;
-import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
-
-/**
- * SVTableCell Editor and Renderer helper functions.
- *
- * @author Jason Height
- */
-public class SVTableUtils {
- private final static Map<Integer, HSSFColor> colors = HSSFColor.getIndexHash();
- /**
- * Description of the Field
- */
- public final static Color black = getAWTColor(HSSFColorPredefined.BLACK);
- /**
- * Description of the Field
- */
- public final static Color white = getAWTColor(HSSFColorPredefined.WHITE);
- /**
- * Description of the Field
- */
- public static final Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
-
-
- /**
- * Creates a new font for a specific cell style
- */
- public static Font makeFont(HSSFFont font) {
- boolean isbold = font.getBold();
- boolean isitalics = font.getItalic();
- int fontstyle = Font.PLAIN;
- if (isbold) {
- fontstyle = Font.BOLD;
- }
- if (isitalics) {
- fontstyle = fontstyle | Font.ITALIC;
- }
-
- int fontheight = font.getFontHeightInPoints();
- if (fontheight == 9) {
- //fix for stupid ol Windows
- fontheight = 10;
- }
-
- return new Font(font.getFontName(), fontstyle, fontheight);
- }
-
- /**
- * This method retrieves the AWT Color representation from the colour hash table
- */
- /* package */
- static Color getAWTColor(int index, Color deflt) {
- HSSFColor clr = colors.get(index);
- if (clr == null) {
- return deflt;
- }
- short[] rgb = clr.getTriplet();
- return new Color(rgb[0], rgb[1], rgb[2]);
- }
-
- /* package */
- static Color getAWTColor(HSSFColorPredefined clr) {
- short[] rgb = clr.getTriplet();
- return new Color(rgb[0], rgb[1], rgb[2]);
- }
-}
diff --git a/src/examples/src/org/apache/poi/hssf/view/SViewer.java b/src/examples/src/org/apache/poi/hssf/view/SViewer.java
deleted file mode 100644
index d3c4cbecaa..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/SViewer.java
+++ /dev/null
@@ -1,197 +0,0 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-
-package org.apache.poi.hssf.view;
-
-import java.awt.AWTEvent;
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.Toolkit;
-import java.awt.event.WindowEvent;
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import javax.swing.JApplet;
-
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-
-/**
- * Sheet Viewer - Views XLS files via HSSF. Can be used as an applet with
- * filename="" or as a applications (pass the filename as the first parameter).
- * Or you can pass it a URL in a "url" parameter when run as an applet or just
- * that first parameter must start with http:// and it will guess its a url. I
- * only tested it as an applet though, so it probably won't work...you fix it.
- *
- * @author Andrew C. Oliver
- * @author Jason Height
- */
-public class SViewer extends JApplet {
- private SViewerPanel panel;
- boolean isStandalone;
- String filename;
-
- /**
- * Get a parameter value
- */
- public String getParameter(String key, String def) {
- return isStandalone ? System.getProperty(key, def) :
- (getParameter(key) != null ? getParameter(key) : def);
- }
-
- /**
- * Construct the applet
- */
- public SViewer() {
- }
-
- /**
- * Initialize the applet
- */
- @Override
- @SuppressWarnings("squid:S1148")
- public void init() {
- try {
- jbInit();
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- /**
- * Component initialization
- */
- private void jbInit() throws Exception {
- boolean isurl = false;
- if (filename == null) {
- filename = getParameter("filename");
- }
-
- if (filename == null || filename.contains("://")) {
- isurl = true;
- if (filename == null) {
- filename = getParameter("url");
- }
- }
-
- final HSSFWorkbook wb;
- try (InputStream is = isurl ? getXLSFromURL(filename) : new FileInputStream(filename)) {
- wb = new HSSFWorkbook(is);
- }
-
- panel = new SViewerPanel(wb, false);
- getContentPane().setLayout(new BorderLayout());
- getContentPane().add(panel, BorderLayout.CENTER);
- }
-
- /**
- * Start the applet
- */
- @Override
- public void start() {
- }
-
- /**
- * Stop the applet
- */
- @Override
- public void stop() {
- }
-
- /**
- * Destroy the applet
- */
- @Override
- public void destroy() {
- }
-
- /**
- * Get Applet information
- */
- @Override
- public String getAppletInfo() {
- return "Applet Information";
- }
-
- /**
- * Get parameter info
- */
- @Override
- public String[][] getParameterInfo() {
- return null;
- }
-
- /**
- * opens a url and returns an inputstream
- */
- private InputStream getXLSFromURL(String urlstring) throws MalformedURLException, IOException {
- URL url = new URL(urlstring);
- URLConnection uc = url.openConnection();
- String field = uc.getHeaderField(0);
- for (int i = 0; field != null; i++) {
- System.out.println(field);
- field = uc.getHeaderField(i);
- }
- return new BufferedInputStream(uc.getInputStream());
- }
-
-
- /**
- * Main method
- */
- public static void main(String[] args) {
- if (args.length < 1) {
- throw new IllegalArgumentException("A filename to view must be supplied as the first argument, but none was given");
- }
-
- SViewer applet = new SViewer();
- applet.isStandalone = true;
- applet.filename = args[0];
- Frame frame;
- frame = new Frame() {
- @Override
- protected void processWindowEvent(WindowEvent e) {
- super.processWindowEvent(e);
- if (e.getID() == WindowEvent.WINDOW_CLOSING) {
- System.exit(0);
- }
- }
-
- @Override
- public synchronized void setTitle(String title) {
- super.setTitle(title);
- enableEvents(AWTEvent.WINDOW_EVENT_MASK);
- }
- };
- frame.setTitle("Applet Frame");
- frame.add(applet, BorderLayout.CENTER);
- applet.init();
- applet.start();
- frame.setSize(400, 320);
- Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
- frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
- frame.setVisible(true);
- }
-}
diff --git a/src/examples/src/org/apache/poi/hssf/view/SViewerPanel.java b/src/examples/src/org/apache/poi/hssf/view/SViewerPanel.java
deleted file mode 100644
index 09332b13f8..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/SViewerPanel.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hssf.view;
-
-import java.awt.AWTEvent;
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Insets;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.WindowEvent;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JComponent;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.JScrollPane;
-import javax.swing.JTabbedPane;
-import javax.swing.JTable;
-import javax.swing.table.JTableHeader;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableColumnModel;
-
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-
-/**
- * This class presents the sheets to the user.
- */
-public class SViewerPanel extends JPanel {
- /**
- * This field is the magic number to convert from a Character width to a
- * java pixel width.
- * <p>
- * When the "normal" font size in a workbook changes, this effects all
- * of the heights and widths. Unfortunately there is no way to retrieve this
- * information, hence the MAGIC number.
- * <p>
- * This number may only work for the normal style font size of Arial size 10.
- */
- private static final int magicCharFactor = 7;
- /**
- * Reference to the wookbook that is being displayed
- */
- /* package */ HSSFWorkbook wb;
- /**
- * Reference to the tabs component
- */
- /* package */ JTabbedPane sheetPane;
- /**
- * Reference to the cell renderer that is used to render all cells
- */
- private SVTableCellRenderer cellRenderer;
- /**
- * Reference to the cell editor that is used to edit all cells.
- * Only constructed if editing is allowed
- */
- private SVTableCellEditor cellEditor;
- /**
- * Flag indicating if editing is allowed. Otherwise the viewer is in
- * view only mode.
- */
- private boolean allowEdits;
-
- /**
- * Construct the representation of the workbook
- */
- public SViewerPanel(HSSFWorkbook wb, boolean allowEdits) {
- this.wb = wb;
- this.allowEdits = allowEdits;
-
- initialiseGui();
- }
-
- private void initialiseGui() {
- cellRenderer = new SVTableCellRenderer(this.wb);
- if (allowEdits)
- cellEditor = new SVTableCellEditor(this.wb);
-
- //Initialise the Panel
- sheetPane = new JTabbedPane(JTabbedPane.BOTTOM);
-
- if (allowEdits)
- sheetPane.addMouseListener(createTabListener());
- int sheetCount = wb.getNumberOfSheets();
- for (int i = 0; i < sheetCount; i++) {
- String sheetName = wb.getSheetName(i);
- //Add the new sheet to the tabbed pane
- sheetPane.addTab(sheetName, makeSheetView(wb.getSheetAt(i)));
- }
- setLayout(new BorderLayout());
- add(sheetPane, BorderLayout.CENTER);
- }
-
- protected JComponent makeSheetView(HSSFSheet sheet) {
- JTable sheetView = new JTable(new SVTableModel(sheet));
- sheetView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
- sheetView.setDefaultRenderer(HSSFCell.class, cellRenderer);
- if (allowEdits)
- sheetView.setDefaultEditor(HSSFCell.class, cellEditor);
- JTableHeader header = sheetView.getTableHeader();
- //Dont allow column reordering
- header.setReorderingAllowed(false);
- //Only allow column resizing if editing is allowed
- header.setResizingAllowed(allowEdits);
-
- //Set the columns the correct size
- TableColumnModel columns = sheetView.getColumnModel();
- for (int i = 0; i < columns.getColumnCount(); i++) {
- TableColumn column = columns.getColumn(i);
- int width = sheet.getColumnWidth(i);
- //256 is because the width is in 256ths of a character
- column.setPreferredWidth(width / 256 * magicCharFactor);
- }
-
- //Set the rows to the correct size
- int rows = sheet.getPhysicalNumberOfRows();
- Insets insets = cellRenderer.getInsets();
- //Need to include the insets in the calculation of the row height to use.
- int extraHeight = insets.bottom + insets.top;
- for (int i = 0; i < rows; i++) {
- HSSFRow row = sheet.getRow(i);
- if (row == null) {
- sheetView.setRowHeight(i, (int) sheet.getDefaultRowHeightInPoints() + extraHeight);
- } else {
- sheetView.setRowHeight(i, (int) row.getHeightInPoints() + extraHeight);
- }
- }
-
- //Add the row header to the sheet
- SVRowHeader rowHeader = new SVRowHeader(sheet, sheetView, extraHeight);
- JScrollPane scroll = new JScrollPane(sheetView);
- scroll.setRowHeaderView(rowHeader);
- return scroll;
- }
-
- @Override
- public void paint(Graphics g) {
- //JMH I am only overriding this to get a picture of the time taken to paint
- long start = System.currentTimeMillis();
- super.paint(g);
- long elapsed = System.currentTimeMillis() - start;
- System.out.println("Paint time = " + elapsed);
- }
-
- protected MouseListener createTabListener() {
- return new TabListener();
- }
-
- /**
- * This class defines the default MouseListener that listens to
- * mouse events in the tabbed pane
- * <p>
- * The default is to popup a menu when the event occurs over a tab
- */
- private class TabListener implements MouseListener {
- private final JPopupMenu popup;
-
- public TabListener() {
- popup = new JPopupMenu("Sheet");
- popup.add(createInsertSheetAction());
- popup.add(createDeleteSheetAction());
- popup.add(createRenameSheetAction());
- }
-
- protected Action createInsertSheetAction() {
- return new InsertSheetAction();
- }
-
- protected Action createDeleteSheetAction() {
- return new DeleteSheetAction();
- }
-
- protected Action createRenameSheetAction() {
- return new RenameSheetAction();
- }
-
-
- /**
- * This method will display the popup if the mouseevent is a popup event
- * and the event occurred over a tab
- */
- protected void checkPopup(MouseEvent e) {
- if (e.isPopupTrigger()) {
- int tab = sheetPane.getUI().tabForCoordinate(sheetPane, e.getX(), e.getY());
- if (tab != -1) {
- popup.show(sheetPane, e.getX(), e.getY());
- }
- }
- }
-
- @Override
- public void mouseClicked(MouseEvent e) {
- checkPopup(e);
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- checkPopup(e);
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- checkPopup(e);
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
- }
-
- /**
- * This class defines the action that is performed when the sheet is renamed
- */
- private class RenameSheetAction extends AbstractAction {
- public RenameSheetAction() {
- super("Rename");
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- int tabIndex = sheetPane.getSelectedIndex();
- if (tabIndex != -1) {
- String newSheetName = JOptionPane.showInputDialog(sheetPane, "Enter a new Sheetname", "Rename Sheet", JOptionPane.QUESTION_MESSAGE);
- if (newSheetName != null) {
- wb.setSheetName(tabIndex, newSheetName);
- sheetPane.setTitleAt(tabIndex, newSheetName);
- }
- }
- }
- }
-
- /**
- * This class defines the action that is performed when a sheet is inserted
- */
- private class InsertSheetAction extends AbstractAction {
- public InsertSheetAction() {
- super("Insert");
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- //Create a new sheet then search for the sheet and make sure that the
- //sheetPane shows it.
- HSSFSheet newSheet = wb.createSheet();
- for (int i = 0; i < wb.getNumberOfSheets(); i++) {
- HSSFSheet sheet = wb.getSheetAt(i);
- if (newSheet == sheet) {
- sheetPane.insertTab(wb.getSheetName(i), null, makeSheetView(sheet), null, i);
- }
- }
- }
- }
-
- /**
- * This class defines the action that is performed when the sheet is deleted
- */
- private class DeleteSheetAction extends AbstractAction {
- public DeleteSheetAction() {
- super("Delete");
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- int tabIndex = sheetPane.getSelectedIndex();
- if (tabIndex != -1) {
- if (JOptionPane.showConfirmDialog(sheetPane, "Are you sure that you want to delete the selected sheet", "Delete Sheet?", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
- wb.removeSheetAt(tabIndex);
- sheetPane.remove(tabIndex);
- }
- }
- }
- }
-
- public boolean isEditable() {
- return allowEdits;
- }
-
- /**
- * Main method
- */
- public static void main(String[] args) throws IOException {
- if (args.length < 1) {
- throw new IllegalArgumentException("A filename to view must be supplied as the first argument, but none was given");
- }
-
- try (FileInputStream in = new FileInputStream(args[0]);
- HSSFWorkbook wb = new HSSFWorkbook(in)) {
- SViewerPanel p = new SViewerPanel(wb, true);
- JFrame frame;
- frame = new JFrame() {
- @Override
- protected void processWindowEvent(WindowEvent e) {
- super.processWindowEvent(e);
- if (e.getID() == WindowEvent.WINDOW_CLOSING) {
- System.exit(0);
- }
- }
-
- @Override
- public synchronized void setTitle(String title) {
- super.setTitle(title);
- enableEvents(AWTEvent.WINDOW_EVENT_MASK);
- }
- };
- frame.setTitle("Viewer Frame");
- frame.getContentPane().add(p, BorderLayout.CENTER);
- frame.setSize(800, 640);
- Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
- frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
- frame.setVisible(true);
- }
- }
-}
diff --git a/src/examples/src/org/apache/poi/hssf/view/brush/BasicBrush.java b/src/examples/src/org/apache/poi/hssf/view/brush/BasicBrush.java
deleted file mode 100644
index db36b83265..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/brush/BasicBrush.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hssf.view.brush;
-
-import java.awt.*;
-
-/**
- * This is a basic brush that just draws the line with the given parameters.
- * This is a {@link BasicStroke} object that can be used as a {@link Brush}.
- *
- * @author Ken Arnold, Industrious Media LLC
- * @see BasicStroke
- */
-public class BasicBrush extends BasicStroke implements Brush {
- /**
- * Creates a new basic brush with the given width. Invokes {@link
- * BasicStroke#BasicStroke(float)}
- *
- * @param width The brush width.
- *
- * @see BasicStroke#BasicStroke(float)
- */
- public BasicBrush(float width) {
- super(width);
- }
-
- /**
- * Creates a new basic brush with the given width, cap, and join. Invokes
- * {@link BasicStroke#BasicStroke(float,int,int)}
- *
- * @param width The brush width.
- * @param cap The capping style.
- * @param join The join style.
- *
- * @see BasicStroke#BasicStroke(float, int, int)
- */
- public BasicBrush(float width, int cap, int join) {
- super(width, cap, join);
- }
-
- /**
- * Creates a new basic brush with the given parameters. Invokes {@link
- * BasicStroke#BasicStroke(float,int,int,float,float[],float)} with a miter
- * limit of 11 (the normal default value).
- *
- * @param width The brush width.
- * @param cap The capping style.
- * @param join The join style.
- * @param dashes The dash intervals.
- * @param dashPos The intial dash position in the dash intervals.
- *
- * @see BasicStroke#BasicStroke(float, int, int, float, float[], float)
- */
- public BasicBrush(float width, int cap, int join, float[] dashes,
- int dashPos) {
- super(width, cap, join, 11.0f, dashes, dashPos);
- }
-} \ No newline at end of file
diff --git a/src/examples/src/org/apache/poi/hssf/view/brush/Brush.java b/src/examples/src/org/apache/poi/hssf/view/brush/Brush.java
deleted file mode 100644
index 2a8964a512..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/brush/Brush.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hssf.view.brush;
-
-import java.awt.*;
-
-/**
- * This is the type you must implement to create a brush that will be used for a
- * spreadsheet border.
- *
- * @author Ken Arnold, Industrious Media LLC
- */
-public interface Brush extends Stroke {
- /** Returns the width of the brush. */
- float getLineWidth();
-}
diff --git a/src/examples/src/org/apache/poi/hssf/view/brush/DoubleStroke.java b/src/examples/src/org/apache/poi/hssf/view/brush/DoubleStroke.java
deleted file mode 100644
index 01b17ef4d0..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/brush/DoubleStroke.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hssf.view.brush;
-
-import java.awt.*;
-
-/**
- * This Stroke implementation applies a BasicStroke to a shape twice. If you
- * draw with this Stroke, then instead of outlining the shape, you're outlining
- * the outline of the shape.
- *
- * @author Ken Arnold, Industrious Media LLC
- */
-public class DoubleStroke implements Brush {
- BasicStroke stroke1, stroke2; // the two strokes to use
-
- /**
- * Creates a new double-stroke brush. This surrounds a cell with a two
- * lines separated by white space between.
- *
- * @param width1 The width of the blank space in the middle
- * @param width2 The width of the each of the two drawn strokes.
- */
- public DoubleStroke(float width1, float width2) {
- stroke1 = new BasicStroke(width1); // Constructor arguments specify
- stroke2 = new BasicStroke(width2); // the line widths for the strokes
- }
-
- /**
- * Stroke the outline.
- *
- * @param s The shape in which to stroke.
- *
- * @return The created stroke as a new shape.
- */
- @Override
- public Shape createStrokedShape(Shape s) {
- // Use the first stroke to create an outline of the shape
- Shape outline = stroke1.createStrokedShape(s);
- // Use the second stroke to create an outline of that outline.
- // It is this outline of the outline that will be filled in
- return stroke2.createStrokedShape(outline);
- }
-
- /** {@inheritDoc} */
- @Override
- public float getLineWidth() {
- return stroke1.getLineWidth() + 2 * stroke2.getLineWidth();
- }
-} \ No newline at end of file
diff --git a/src/examples/src/org/apache/poi/hssf/view/brush/PendingPaintings.java b/src/examples/src/org/apache/poi/hssf/view/brush/PendingPaintings.java
deleted file mode 100644
index dcbf8b35c3..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/brush/PendingPaintings.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hssf.view.brush;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.geom.*;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This class is used to hold pending brush paintings. The model is that some
- * border drawing requires drawing strokes after all the cells have been
- * painted. The list of pending paintings can be put in this object during the
- * initial paint of the component, and then executed at the appropriate time,
- * such as at the end of the containing object's {@link
- * JComponent#paintChildren(Graphics)} method.
- * <p>
- * It is up to the parent component to invoke the {@link #paint(Graphics2D)}
- * method of this objet at that appropriate time.
- *
- * @author Ken Arnold, Industrious Media LLC
- */
-public class PendingPaintings {
- /**
- * The name of the client property that holds this object in the parent
- * component.
- */
- public static final String PENDING_PAINTINGS =
- PendingPaintings.class.getSimpleName();
-
- private final List<Painting> paintings;
-
- /** A single painting description. */
- public static class Painting {
- final Stroke stroke;
- final Color color;
- final Shape shape;
- final AffineTransform transform;
-
- /**
- * Creates a new painting description.
- *
- * @param stroke The stroke to paint.
- * @param color The color of the stroke.
- * @param shape The shape of the stroke.
- * @param transform The transformation matrix to use.
- */
- public Painting(Stroke stroke, Color color, Shape shape,
- AffineTransform transform) {
-
- this.color = color;
- this.shape = shape;
- this.stroke = stroke;
- this.transform = transform;
- }
-
- /**
- * Draw the painting.
- *
- * @param g The graphics object to use to draw with.
- */
- public void draw(Graphics2D g) {
- g.setTransform(transform);
- g.setStroke(stroke);
- g.setColor(color);
- g.draw(shape);
- }
- }
-
- /**
- * Creates a new object on the given parent. The created object will be
- * stored as a client property.
- *
- * @param parent
- */
- public PendingPaintings(JComponent parent) {
- paintings = new ArrayList<>();
- parent.putClientProperty(PENDING_PAINTINGS, this);
- }
-
- /** Drops all pending paintings. */
- public void clear() {
- paintings.clear();
- }
-
- /**
- * Paints all pending paintings. Once they have been painted they are
- * removed from the list of pending paintings (they aren't pending anymore,
- * after all).
- *
- * @param g The graphics object to draw with.
- */
- public void paint(Graphics2D g) {
- g.setBackground(Color.CYAN);
- AffineTransform origTransform = g.getTransform();
- for (Painting c : paintings) {
- c.draw(g);
- }
- g.setTransform(origTransform);
-
- clear();
- }
-
- /**
- * Adds a new pending painting to the list on the given component. This
- * will find the first ancestor that has a {@link PendingPaintings} client
- * property, starting with the component itself.
- *
- * @param c The component for which the painting is being added.
- * @param g The graphics object to draw with.
- * @param stroke The stroke to draw.
- * @param color The color to draw with.
- * @param shape The shape to stroke.
- */
- public static void add(JComponent c, Graphics2D g, Stroke stroke,
- Color color, Shape shape) {
-
- add(c, new Painting(stroke, color, shape, g.getTransform()));
- }
-
- /**
- * Adds a new pending painting to the list on the given component. This
- * will find the first ancestor that has a {@link PendingPaintings} client
- * property, starting with the component itself.
- *
- * @param c The component for which the painting is being added.
- * @param newPainting The new painting.
- */
- public static void add(JComponent c, Painting newPainting) {
- PendingPaintings pending = pendingPaintingsFor(c);
- if (pending != null) {
- pending.paintings.add(newPainting);
- }
- }
-
- /**
- * Returns the pending painting object for the given component, if any. This
- * is retrieved from the first object found that has a {@link
- * #PENDING_PAINTINGS} client property, starting with this component and
- * looking up its ancestors (parent, parent's parent, etc.)
- * <p>
- * This allows any descendant of a component that has a {@link
- * PendingPaintings} property to add its own pending paintings.
- *
- * @param c The component for which the painting is being added.
- *
- * @return The pending painting object for that component, or <tt>null</tt>
- * if there is none.
- */
- public static PendingPaintings pendingPaintingsFor(JComponent c) {
- for (Component parent = c;
- parent != null;
- parent = parent.getParent()) {
- if (parent instanceof JComponent) {
- JComponent jc = (JComponent) parent;
- Object pd = jc.getClientProperty(PENDING_PAINTINGS);
- if (pd != null)
- return (PendingPaintings) pd;
- }
- }
- return null;
- }
-} \ No newline at end of file
diff --git a/src/examples/src/org/apache/poi/hssf/view/brush/package-info.java b/src/examples/src/org/apache/poi/hssf/view/brush/package-info.java
deleted file mode 100644
index cf71cf6a13..0000000000
--- a/src/examples/src/org/apache/poi/hssf/view/brush/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-/**
- * This package contains some brushes that are used when drawing borders for Excel cells.
- */
-package org.apache.poi.hssf.view.brush; \ No newline at end of file
diff --git a/src/examples/src/org/apache/poi/poifs/poibrowser/DocumentDescriptor.java b/src/examples/src/org/apache/poi/poifs/poibrowser/DocumentDescriptor.java
deleted file mode 100644
index e93c23b79a..0000000000
--- a/src/examples/src/org/apache/poi/poifs/poibrowser/DocumentDescriptor.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.poifs.poibrowser;
-
-import java.io.IOException;
-
-import org.apache.poi.poifs.filesystem.DocumentInputStream;
-import org.apache.poi.poifs.filesystem.POIFSDocumentPath;
-import org.apache.poi.util.IOUtils;
-
-/**
- * <p>Describes the most important (whatever that is) features of a
- * {@link POIFSDocumentPath}.</p>
- */
-class DocumentDescriptor
-{
-
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
-
- String name;
- POIFSDocumentPath path;
- DocumentInputStream stream;
-
- int size;
- byte[] bytes;
-
-
- /**
- * <p>Creates a {@link DocumentDescriptor}.</p>
- *
- * @param name The stream's name.
- *
- * @param path The stream's path in the POI filesystem hierarchy.
- *
- * @param stream The stream.
- *
- * @param nrOfBytes The maximum number of bytes to display in a
- * dump starting at the beginning of the stream.
- */
- public DocumentDescriptor(final String name,
- final POIFSDocumentPath path,
- final DocumentInputStream stream,
- final int nrOfBytes) {
- this.name = name;
- this.path = path;
- this.stream = stream;
- try {
- if (stream.markSupported()) {
- stream.mark(nrOfBytes);
- bytes = IOUtils.toByteArray(stream, nrOfBytes, MAX_RECORD_LENGTH);
- stream.reset();
- } else {
- bytes = new byte[0];
- }
- size = bytes.length + stream.available();
- } catch (IOException ex) {
- System.out.println(ex);
- }
- }
-
-}
diff --git a/src/examples/src/org/apache/poi/poifs/poibrowser/DocumentDescriptorRenderer.java b/src/examples/src/org/apache/poi/poifs/poibrowser/DocumentDescriptorRenderer.java
deleted file mode 100644
index f3f805c9f3..0000000000
--- a/src/examples/src/org/apache/poi/poifs/poibrowser/DocumentDescriptorRenderer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.poifs.poibrowser;
-
-import java.awt.*;
-import javax.swing.*;
-import javax.swing.tree.*;
-
-import org.apache.poi.util.HexDump;
-
-/**
- * <p>{@link TreeCellRenderer} for a {@link DocumentDescriptor}. The
- * renderer is extremly rudimentary since displays only the document's
- * name, its size and its fist few bytes.</p>
- */
-public class DocumentDescriptorRenderer extends DefaultTreeCellRenderer
-{
-
- @Override
- public Component getTreeCellRendererComponent(final JTree tree,
- final Object value,
- final boolean selectedCell,
- final boolean expanded,
- final boolean leaf,
- final int row,
- final boolean hasCellFocus)
- {
- final DocumentDescriptor d = (DocumentDescriptor)
- ((DefaultMutableTreeNode) value).getUserObject();
- final JPanel p = new JPanel();
- final JTextArea text = new JTextArea();
- text.append(renderAsString(d));
- text.setFont(new Font("Monospaced", Font.PLAIN, 10));
- p.add(text);
- if (selectedCell) {
- Util.invert(text);
- }
- return p;
- }
-
-
- /**
- * <p>Renders {@link DocumentDescriptor} as a string.</p>
- */
- protected String renderAsString(final DocumentDescriptor d) {
- return "Name: " +
- d.name +
- " " +
- HexDump.toHex(d.name) +
- "\n" +
- "Size: " +
- d.size +
- " bytes\n" +
- "First bytes: " +
- HexDump.toHex(d.bytes);
- }
-}
diff --git a/src/examples/src/org/apache/poi/poifs/poibrowser/ExtendableTreeCellRenderer.java b/src/examples/src/org/apache/poi/poifs/poibrowser/ExtendableTreeCellRenderer.java
deleted file mode 100644
index a2a0339b51..0000000000
--- a/src/examples/src/org/apache/poi/poifs/poibrowser/ExtendableTreeCellRenderer.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.poifs.poibrowser;
-
-import java.awt.*;
-import javax.swing.*;
-import javax.swing.tree.*;
-import java.util.*;
-
-/**
- * <p>This is a {@link TreeCellRenderer} implementation which is able
- * to render arbitrary objects. The {@link ExtendableTreeCellRenderer}
- * does not do the rendering itself but instead dispatches to
- * class-specific renderers. A class/renderer pair must be registered
- * using the {@link #register} method. If a class has no registered
- * renderer, the renderer of its closest superclass is used. Since the
- * {@link ExtendableTreeCellRenderer} always has a default renderer
- * for the {@link Object} class, rendering is always possible. The
- * default {@link Object} renderer can be replaced by another renderer
- * but it cannot be unregistered.</p>
- */
-public class ExtendableTreeCellRenderer implements TreeCellRenderer
-{
-
- /**
- * <p>Maps classes to renderers.</p>
- */
- protected Map<Class<?>,TreeCellRenderer> renderers;
-
-
-
- public ExtendableTreeCellRenderer()
- {
- renderers = new HashMap<>();
- register(Object.class, new DefaultTreeCellRenderer()
- {
- @Override
- public Component getTreeCellRendererComponent
- (JTree tree, Object value, boolean selectedCell,
- boolean expanded, boolean leaf, int row, boolean hasCellFocus)
- {
- final String s = value.toString();
- final JLabel l = new JLabel(s + " ");
- if (selected)
- {
- Util.invert(l);
- l.setOpaque(true);
- }
- return l;
- }
- });
- }
-
-
-
- /**
- * <p>Registers a renderer for a class.</p>
- **/
- public void register(final Class<?> c, final TreeCellRenderer renderer)
- {
- renderers.put(c, renderer);
- }
-
-
-
- /**
- * <p>Unregisters a renderer for a class. The renderer for the
- * {@link Object} class cannot be unregistered.</p>
- */
- public void unregister(final Class<?> c)
- {
- if (c == Object.class)
- throw new IllegalArgumentException
- ("Renderer for Object cannot be unregistered.");
- renderers.put(c, null);
- }
-
-
-
- /**
- * <p>Renders an object in a tree cell depending of the object's
- * class.</p>
- *
- * @see TreeCellRenderer#getTreeCellRendererComponent
- */
- @Override
- public Component getTreeCellRendererComponent
- (final JTree tree, final Object value, final boolean selected,
- final boolean expanded, final boolean leaf, final int row,
- final boolean hasFocus)
- {
- final String NULL = "null";
- TreeCellRenderer r;
- Object userObject;
- if (value == null)
- userObject = NULL;
- else
- {
- userObject = ((DefaultMutableTreeNode) value).getUserObject();
- if (userObject == null)
- userObject = NULL;
- }
- r = findRenderer(userObject.getClass());
- return r.getTreeCellRendererComponent
- (tree, value, selected, expanded, leaf, row,
- hasFocus);
- }
-
-
-
- /**
- * <p>Find the renderer for the specified class.</p>
- */
- protected TreeCellRenderer findRenderer(final Class<?> c)
- {
- final TreeCellRenderer r = renderers.get(c);
- if (r != null)
- /* The class has a renderer. */
- return r;
-
- /* The class has no renderer, try the superclass, if any. */
- final Class<?> superclass = c.getSuperclass();
- if (superclass != null) {
- return findRenderer(superclass);
- }
- return null;
- }
-
-}
diff --git a/src/examples/src/org/apache/poi/poifs/poibrowser/POIBrowser.java b/src/examples/src/org/apache/poi/poifs/poibrowser/POIBrowser.java
deleted file mode 100644
index a70f5edd00..0000000000
--- a/src/examples/src/org/apache/poi/poifs/poibrowser/POIBrowser.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.poifs.poibrowser;
-
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.io.File;
-import java.io.IOException;
-
-import javax.swing.JFrame;
-import javax.swing.JScrollPane;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.MutableTreeNode;
-
-import org.apache.poi.poifs.eventfilesystem.POIFSReader;
-
-/**
- * <p>The main class of the POI Browser. It shows the structure of POI
- * filesystems (Microsoft Office documents) in a {@link
- * JTree}. Specify their filenames on the command line!</p>
- *
- * @see POIFSReader
- */
-@SuppressWarnings("serial")
-public class POIBrowser extends JFrame
-{
-
-
- /**
- * <p>Takes a bunch of file names as command line parameters,
- * opens each of them as a POI filesystem and displays their
- * internal structures in a {@link JTree}.</p>
- */
- public static void main(String[] args)
- {
- new POIBrowser().run(args);
- }
-
- protected void run(String[] args)
- {
- addWindowListener(new WindowAdapter()
- {
- @Override
- public void windowClosing(WindowEvent e)
- {
- System.exit(0);
- }
- });
-
- /* Create the tree model with a root node. The latter is
- * invisible but it must be present because a tree model
- * always needs a root.
- *
- * The tree's root node must be visible to all methods.
- */
- MutableTreeNode rootNode = new DefaultMutableTreeNode("POI Filesystems");
- DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
-
- /* Create the tree UI element. */
- final JTree treeUI = new JTree(treeModel);
- getContentPane().add(new JScrollPane(treeUI));
-
- /* Add the POI filesystems to the tree. */
- int displayedFiles = 0;
- for (final String filename : args) {
- try {
- POIFSReader r = new POIFSReader();
- r.registerListener(new TreeReaderListener(filename, rootNode));
- r.read(new File(filename));
- displayedFiles++;
- } catch (IOException ex) {
- System.err.println(filename + ": " + ex);
- } catch (Exception t) {
- System.err.println("Unexpected exception while reading \"" +
- filename + "\":");
- t.printStackTrace(System.err);
- }
- }
-
- /* Exit if there is no file to display (none specified or only
- * files with problems). */
- if (displayedFiles == 0)
- {
- System.out.println("No POI filesystem(s) to display.");
- System.exit(0);
- }
-
- /* Make the tree UI element visible. */
- treeUI.setRootVisible(true);
- treeUI.setShowsRootHandles(true);
- ExtendableTreeCellRenderer etcr = new ExtendableTreeCellRenderer();
- etcr.register(DocumentDescriptor.class,
- new DocumentDescriptorRenderer());
- etcr.register(PropertySetDescriptor.class,
- new PropertySetDescriptorRenderer());
- treeUI.setCellRenderer(etcr);
- setSize(600, 450);
- setTitle("POI Browser 0.09");
- setVisible(true);
- }
-
-}
diff --git a/src/examples/src/org/apache/poi/poifs/poibrowser/PropertySetDescriptor.java b/src/examples/src/org/apache/poi/poifs/poibrowser/PropertySetDescriptor.java
deleted file mode 100644
index f9658ae03f..0000000000
--- a/src/examples/src/org/apache/poi/poifs/poibrowser/PropertySetDescriptor.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.poifs.poibrowser;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-import org.apache.poi.hpsf.MarkUnsupportedException;
-import org.apache.poi.hpsf.NoPropertySetStreamException;
-import org.apache.poi.hpsf.PropertySet;
-import org.apache.poi.hpsf.PropertySetFactory;
-import org.apache.poi.poifs.filesystem.DocumentInputStream;
-import org.apache.poi.poifs.filesystem.POIFSDocumentPath;
-
-/**
- * <p>Describes the most important (whatever that is) features of a
- * stream containing a {@link PropertySet}.</p>
- */
-public class PropertySetDescriptor extends DocumentDescriptor
-{
-
- protected PropertySet propertySet;
-
- /**
- * <p>Returns this {@link PropertySetDescriptor}'s {@link
- * PropertySet}.</p>
- */
- public PropertySet getPropertySet()
- {
- return propertySet;
- }
-
-
-
- /**
- * <p>Creates a {@link PropertySetDescriptor} by reading a {@link
- * PropertySet} from a {@link DocumentInputStream}.</p>
- *
- * @param name The stream's name.
- *
- * @param path The stream's path in the POI filesystem hierarchy.
- *
- * @param stream The stream.
- *
- * @param nrOfBytesToDump The maximum number of bytes to display in a
- * dump starting at the beginning of the stream.
- */
- public PropertySetDescriptor(final String name,
- final POIFSDocumentPath path,
- final DocumentInputStream stream,
- final int nrOfBytesToDump)
- throws NoPropertySetStreamException,
- MarkUnsupportedException, UnsupportedEncodingException,
- IOException
- {
- super(name, path, stream, nrOfBytesToDump);
- propertySet = PropertySetFactory.create(stream);
- }
-
-}
diff --git a/src/examples/src/org/apache/poi/poifs/poibrowser/PropertySetDescriptorRenderer.java b/src/examples/src/org/apache/poi/poifs/poibrowser/PropertySetDescriptorRenderer.java
deleted file mode 100644
index 153dc5e205..0000000000
--- a/src/examples/src/org/apache/poi/poifs/poibrowser/PropertySetDescriptorRenderer.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.poifs.poibrowser;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.swing.JPanel;
-import javax.swing.JTextArea;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultMutableTreeNode;
-
-import org.apache.poi.hpsf.Property;
-import org.apache.poi.hpsf.PropertySet;
-import org.apache.poi.hpsf.Section;
-import org.apache.poi.hpsf.SummaryInformation;
-import org.apache.poi.util.HexDump;
-
-/**
- * <p>Renders a {@link PropertySetDescriptor} by more or less dumping
- * the stuff into a {@link JTextArea}.</p>
- */
-public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer
-{
-
- @Override
- public Component getTreeCellRendererComponent(final JTree tree,
- final Object value,
- final boolean selectedCell,
- final boolean expanded,
- final boolean leaf,
- final int row,
- final boolean hasCellFocus)
- {
- final PropertySetDescriptor d = (PropertySetDescriptor)
- ((DefaultMutableTreeNode) value).getUserObject();
- final PropertySet ps = d.getPropertySet();
- final JPanel p = new JPanel();
- final JTextArea text = new JTextArea();
- text.setBackground(new Color(200, 255, 200));
- text.setFont(new Font("Monospaced", Font.PLAIN, 10));
- text.append(renderAsString(d));
- text.append("\nByte order: ");
- text.append(HexDump.toHex((short) ps.getByteOrder()));
- text.append("\nFormat: ");
- text.append(HexDump.toHex((short) ps.getFormat()));
- text.append("\nOS version: ");
- text.append(HexDump.toHex(ps.getOSVersion()));
- text.append("\nClass ID: ");
- text.append(HexDump.toHex(ps.getClassID().getBytes()));
- text.append("\nSection count: " + ps.getSectionCount());
- text.append(sectionsToString(ps.getSections()));
- p.add(text);
-
- if (ps instanceof SummaryInformation)
- {
- /* Use the convenience methods. */
- final SummaryInformation si = (SummaryInformation) ps;
- text.append("\n");
- text.append("\nTitle: " + si.getTitle());
- text.append("\nSubject: " + si.getSubject());
- text.append("\nAuthor: " + si.getAuthor());
- text.append("\nKeywords: " + si.getKeywords());
- text.append("\nComments: " + si.getComments());
- text.append("\nTemplate: " + si.getTemplate());
- text.append("\nLast Author: " + si.getLastAuthor());
- text.append("\nRev. Number: " + si.getRevNumber());
- text.append("\nEdit Time: " + si.getEditTime());
- text.append("\nLast Printed: " + si.getLastPrinted());
- text.append("\nCreate Date/Time: " + si.getCreateDateTime());
- text.append("\nLast Save Date/Time: " + si.getLastSaveDateTime());
- text.append("\nPage Count: " + si.getPageCount());
- text.append("\nWord Count: " + si.getWordCount());
- text.append("\nChar Count: " + si.getCharCount());
- // text.append("\nThumbnail: " + si.getThumbnail());
- text.append("\nApplication Name: " + si.getApplicationName());
- text.append("\nSecurity: " + si.getSecurity());
- }
-
- if (selectedCell)
- Util.invert(text);
- return p;
- }
-
-
-
- /**
- * <p>Returns a string representation of a list of {@link
- * Section}s.</p>
- */
- protected String sectionsToString(final List<Section> sections)
- {
- final StringBuilder b = new StringBuilder();
- int count = 1;
- for (Iterator<Section> i = sections.iterator(); i.hasNext();)
- {
- Section s = i.next();
- String d = toString(s, "Section " + count++);
- b.append(d);
- }
- return b.toString();
- }
-
-
-
- /**
- * <p>Returns a string representation of a {@link Section}.</p>
- * @param s the section
- * @param name the section's name
- * @return a string representation of the {@link Section}
- */
- protected String toString(final Section s, final String name)
- {
- final StringBuilder b = new StringBuilder();
- b.append("\n" + name + " Format ID: ");
- b.append(HexDump.toHex(s.getFormatID().getBytes()));
- b.append("\n" + name + " Offset: " + s.getOffset());
- b.append("\n" + name + " Section size: " + s.getSize());
- b.append("\n" + name + " Property count: " + s.getPropertyCount());
-
- final Property[] properties = s.getProperties();
- for (int i = 0; i < properties.length; i++)
- {
- final Property p = properties[i];
- final long id = p.getID();
- final long type = p.getType();
- final Object value = p.getValue();
- b.append('\n');
- b.append(name);
- b.append(", Name: ");
- b.append(id);
- b.append(" (");
- b.append(s.getPIDString(id));
- b.append("), Type: ");
- b.append(type);
- b.append(", Value: ");
- if (value instanceof byte[]) {
- byte[] buf = new byte[4];
- System.arraycopy(value, 0, buf, 0, 4);
- b.append(HexDump.toHex(buf));
- b.append(' ');
- System.arraycopy(value, ((byte[])value).length - 4, buf, 0, 4);
- } else if (value != null) {
- b.append(value);
- } else {
- b.append("null");
- }
- }
- return b.toString();
- }
-
-}
diff --git a/src/examples/src/org/apache/poi/poifs/poibrowser/TreeReaderListener.java b/src/examples/src/org/apache/poi/poifs/poibrowser/TreeReaderListener.java
deleted file mode 100644
index a7d978d234..0000000000
--- a/src/examples/src/org/apache/poi/poifs/poibrowser/TreeReaderListener.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.poifs.poibrowser;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.MutableTreeNode;
-
-import org.apache.poi.hpsf.HPSFException;
-import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
-import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;
-import org.apache.poi.poifs.filesystem.DocumentInputStream;
-import org.apache.poi.poifs.filesystem.POIFSDocumentPath;
-
-/**
- * <p>Organizes document information in a tree model in order to be
- * e.g. displayed in a Swing {@link javax.swing.JTree}. An instance of this
- * class is created with a root tree node ({@link MutableTreeNode}) and
- * registered as a {@link POIFSReaderListener} with a {@link
- * org.apache.poi.poifs.eventfilesystem.POIFSReader}. While the latter processes
- * a POI filesystem it calls this class' {@link #processPOIFSReaderEvent} for
- * each document it has been registered for. This method appends the document it
- * processes at the appropriate position into the tree rooted at the
- * above mentioned root tree node.</p>
- *
- * <p>The root tree node should be the root tree node of a {@link
- * javax.swing.tree.TreeModel}.</p>
- *
- * <p>A top-level element in the tree model, i.e. an immediate child
- * node of the root node, describes a POI filesystem as such. It is
- * suggested to use the file's name (as seen by the operating system)
- * but it could be any other string.</p>
- *
- * <p>The value of a tree node is a {@link DocumentDescriptor}. Unlike
- * a {@link org.apache.poi.poifs.filesystem.OPOIFSDocument} which may be as heavy
- * as many megabytes, an instance of {@link DocumentDescriptor} is a
- * light-weight object and contains only some meta-information about a
- * document.</p>
- */
-public class TreeReaderListener implements POIFSReaderListener
-{
-
- /**
- * <p>The tree's root node. POI filesystems get attached to this
- * node as children.</p>
- */
- protected MutableTreeNode rootNode;
-
- /**
- * <p>Maps filenames and POI document paths to their associated
- * tree nodes.</p>
- */
- protected Map<Object,MutableTreeNode> pathToNode;
-
- /**
- * <p>The name of the file this {@link TreeReaderListener}
- * processes. It is used to identify a top-level element in the
- * tree. Alternatively any other string can be used. It is just a
- * label which should identify a POI filesystem.</p>
- */
- protected String filename;
-
-
-
- /**
- * <p>Creates a {@link TreeReaderListener} which should then be
- * registered with a
- * {@link org.apache.poi.poifs.eventfilesystem.POIFSReader}.</p>
- *
- * @param filename The name of the POI filesystem, i.e. the name
- * of the file the POI filesystem resides in. Alternatively any
- * other string can be used.
- *
- * @param rootNode All document information will be attached as
- * descendands to this tree node.
- */
- public TreeReaderListener(final String filename,
- final MutableTreeNode rootNode)
- {
- this.filename = filename;
- this.rootNode = rootNode;
- pathToNode = new HashMap<>(15); // Should be a reasonable guess.
- }
-
-
-
- /** <p>The number of bytes to dump.</p> */
- private int nrOfBytes = 50;
-
- public void setNrOfBytes(final int nrOfBytes)
- {
- this.nrOfBytes = nrOfBytes;
- }
-
- public int getNrOfBytes()
- {
- return nrOfBytes;
- }
-
-
-
- /**
- * <p>A document in the POI filesystem has been opened for
- * reading. This method retrieves properties of the document and
- * adds them to a tree model.</p>
- */
- @Override
- public void processPOIFSReaderEvent(final POIFSReaderEvent event)
- {
- DocumentDescriptor d;
- final DocumentInputStream is = event.getStream();
- if (!is.markSupported()) {
- throw new UnsupportedOperationException(is.getClass().getName() +
- " does not support mark().");
- }
-
- /* Try do handle this document as a property set. We receive
- * an exception if is no property set and handle it as a
- * document of some other format. We are not concerned about
- * that document's details. */
- try
- {
- d = new PropertySetDescriptor(event.getName(), event.getPath(),
- is, nrOfBytes);
- }
- catch (HPSFException ex)
- {
- d = new DocumentDescriptor(event.getName(), event.getPath(),
- is, nrOfBytes);
- }
- catch (Exception t)
- {
- throw new RuntimeException("Unexpected exception while processing " + event.getName() + " in " + event.getPath(), t);
- }
-
- is.close();
-
- final MutableTreeNode parentNode = getNode(d.path, filename, rootNode);
- final MutableTreeNode nameNode = new DefaultMutableTreeNode(d.name);
- parentNode.insert(nameNode, 0);
- final MutableTreeNode dNode = new DefaultMutableTreeNode(d);
- nameNode.insert(dNode, 0);
- }
-
-
-
- /**
- * <p>Locates the parent node for a document entry in the tree
- * model. If the parent node does not yet exist it will be
- * created, too. This is done recursively, if needed.</p>
- *
- * @param path The tree node for this path is located.
- *
- * @param fsName The name of the POI filesystem. This is just a
- * string which is displayed in the tree at the top lovel.
- *
- * @param root The root node.
- */
- private MutableTreeNode getNode(final POIFSDocumentPath path,
- final String fsName,
- final MutableTreeNode root)
- {
- MutableTreeNode n = pathToNode.get(path);
- if (n != null) {
- /* Node found in map, just return it. */
- return n;
- }
- if (path.length() == 0)
- {
- /* This is the root path of the POI filesystem. Its tree
- * node is resp. must be located below the tree node of
- * the POI filesystem itself. This is a tree node with the
- * POI filesystem's name (this the operating system file's
- * name) as its key it the path-to-node map. */
- n = pathToNode.get(fsName);
- if (n == null)
- {
- /* A tree node for the POI filesystem does not yet
- * exist. */
- n = new DefaultMutableTreeNode(fsName);
- pathToNode.put(fsName, n);
- root.insert(n, 0);
- }
- return n;
- }
- /* else - The path is somewhere down in the POI filesystem's
- * hierarchy. We need the tree node of this path's parent
- * and attach our new node to it. */
- final String name = path.getComponent(path.length() - 1);
- final POIFSDocumentPath parentPath = path.getParent();
- final MutableTreeNode parentNode =
- getNode(parentPath, fsName, root);
- n = new DefaultMutableTreeNode(name);
- pathToNode.put(path, n);
- parentNode.insert(n, 0);
- return n;
- }
-}
diff --git a/src/examples/src/org/apache/poi/poifs/poibrowser/Util.java b/src/examples/src/org/apache/poi/poifs/poibrowser/Util.java
deleted file mode 100644
index 8e86b18735..0000000000
--- a/src/examples/src/org/apache/poi/poifs/poibrowser/Util.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.poifs.poibrowser;
-
-import java.awt.*;
-import javax.swing.*;
-
-/**
- * <p>Contains various (well, just one at the moment) static utility
- * methods.</p>
- */
-public class Util {
-
- /**
- * <p>Makes a Swing component inverted by swapping its foreground
- * and background colors. Hint: Depending on your needs it might
- * also be a good idea to call <tt>c.setOpaque(true)</tt>.</p>
- */
- public static void invert(JComponent c) {
- Color invBackground = c.getForeground();
- Color invForeground = c.getBackground();
- c.setBackground(invBackground);
- c.setForeground(invForeground);
- }
-}
-