📄 jfreereportresources.java
字号:
/**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://www.jfree.org/jfreereport/index.html
* Project Lead: Thomas Morgner;
*
* (C) Copyright 2000-2003, by Thomas Morgner, Object Refinery Limited and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* -------------------------
* JFreeReportResources.java
* -------------------------
* (C)opyright 2000-2003, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): Thomas Morgner;
*
* $Id: JFreeReportResources.java,v 1.61.2.3 2003/08/24 14:18:11 taqua Exp $
*
*/
package com.jrefinery.report.resources;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.ListResourceBundle;
import javax.swing.ImageIcon;
import javax.swing.KeyStroke;
import com.jrefinery.report.util.Log;
import com.jrefinery.report.JFreeReport;
/**
* English language resources.
*
* @author Thomas Morgner
*/
public class JFreeReportResources extends ListResourceBundle
{
/**
* Default constructor.
*/
public JFreeReportResources()
{
}
/**
* Used to test the resourcebundle for null values.
*
* @param args ignored.
*/
public static void main(final String[] args)
{
Object lastKey = null;
try
{
final Hashtable elements = new Hashtable();
for (int i = 0; i < CONTENTS.length; i++)
{
final Object[] row = CONTENTS[i];
lastKey = row[0];
elements.put(row[0], row[1]);
}
getIcon("com/jrefinery/report/resources/SaveAs16.gif");
}
catch (Exception e)
{
e.printStackTrace();
Log.debug("LastKey read: " + lastKey);
}
System.exit(0);
}
/** The resources. */
private static JFreeReportResources res = new JFreeReportResources();
/**
* Returns an array of localised resources.
*
* @return an array of localised resources.
*/
public Object[][] getContents()
{
return CONTENTS;
}
/**
* Prints all defined resource bundle keys and their assigned values.
*/
public void printAll()
{
final Object[][] c = getContents();
for (int i = 0; i < c.length; i++)
{
final Object[] cc = c[i];
System.out.print(cc[0]);
System.out.print("=");
System.out.println(cc[1]);
}
}
/**
* Creates a transparent image. These can be used for aligning menu items.
*
* @param width the width.
* @param height the height.
*
* @return the image.
*/
public static BufferedImage createTransparentImage(final int width, final int height)
{
final BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
final int[] data = img.getRGB(0, 0, width, height, null, 0, width);
Arrays.fill(data, 0xff000000);
img.setRGB(0, 0, width, height, data, 0, width);
return img;
}
/**
* Attempts to load an image from classpath. If this fails, an empty
* image icon is returned.
*
* @param filename the file name.
*
* @return the image icon.
*/
public static ImageIcon getIcon(final String filename)
{
final URL in = res.getClass().getClassLoader().getResource(filename);
if (in == null)
{
Log.warn("Unable to find file in the class path: " + filename);
return new ImageIcon(createTransparentImage(1, 1));
}
final Image img = Toolkit.getDefaultToolkit().createImage(in);
if (img == null)
{
Log.warn("Unable to instantiate the image: " + filename);
return new ImageIcon(createTransparentImage(1, 1));
}
return new ImageIcon(img);
}
/**
* Creates a platform independed menu keystroke for the given character.
*
* @param character the keystroke character
* @return the generated keystroke object.
*/
protected static final KeyStroke createMenuKeystroke(final int character)
{
try
{
return KeyStroke.getKeyStroke(character, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
}
catch (UnsupportedOperationException use)
{
return KeyStroke.getKeyStroke(character, KeyEvent.CTRL_MASK);
}
}
/** The resources to be localised. */
private static final Object[][] CONTENTS =
{
{"project.name", JFreeReport.getInfo().getName() },
{"project.version", JFreeReport.getInfo().getVersion() },
{"project.info", JFreeReport.getInfo().getInfo() },
{"project.copyright", JFreeReport.getInfo().getCopyright() },
{"action.save-as.name", "Save As PDF..."},
{"action.save-as.description", "Save to PDF format"},
{"action.save-as.mnemonic", new Integer(KeyEvent.VK_A)},
{"action.save-as.accelerator", createMenuKeystroke(KeyEvent.VK_S)},
{"action.save-as.small-icon", getIcon("com/jrefinery/report/resources/SaveAs16.gif")},
{"action.save-as.icon", getIcon("com/jrefinery/report/resources/SaveAs24.gif")},
{"action.export-to-excel.name", "Export to Excel..."},
{"action.export-to-excel.description", "Save to MS-Excel format"},
{"action.export-to-excel.mnemonic", new Integer(KeyEvent.VK_E)},
{"action.export-to-excel.accelerator", createMenuKeystroke(KeyEvent.VK_E)},
// temporarily using the same icon as "Save to PDF", till we have a better one
{"action.export-to-excel.small-icon",
getIcon("com/jrefinery/report/resources/SaveAs16.gif")},
{"action.export-to-excel.icon",
getIcon("com/jrefinery/report/resources/SaveAs24.gif")},
{"action.export-to-html.name", "Export to html..."},
{"action.export-to-html.description", "Save to HTML format"},
{"action.export-to-html.mnemonic", new Integer(KeyEvent.VK_H)},
{"action.export-to-html.accelerator", createMenuKeystroke(KeyEvent.VK_H)},
// temporarily using the same icon as "Save to PDF", till we have a better one
{"action.export-to-html.small-icon",
getIcon("com/jrefinery/report/resources/SaveAs16.gif")},
{"action.export-to-html.icon",
getIcon("com/jrefinery/report/resources/SaveAs24.gif")},
{"action.export-to-csv.name", "Export to CSV..."},
{"action.export-to-csv.description", "Save to CSV format"},
{"action.export-to-csv.mnemonic", new Integer(KeyEvent.VK_C)},
{"action.export-to-csv.accelerator", createMenuKeystroke(KeyEvent.VK_C)},
// temporarily using the same icon as "Save to PDF", till we have a better one
{"action.export-to-csv.small-icon",
getIcon("com/jrefinery/report/resources/SaveAs16.gif")},
{"action.export-to-csv.icon",
getIcon("com/jrefinery/report/resources/SaveAs24.gif")},
{"action.export-to-plaintext.name", "Save as text file..."},
{"action.export-to-plaintext.description", "Save to PlainText format"},
{"action.export-to-plaintext.mnemonic", new Integer(KeyEvent.VK_T)},
{"action.export-to-plaintext.accelerator", createMenuKeystroke(KeyEvent.VK_T)},
// temporarily using the same icon as "Save to PDF", till we have a better one
{"action.export-to-plaintext.small-icon",
getIcon("com/jrefinery/report/resources/SaveAs16.gif")},
{"action.export-to-plaintext.icon",
getIcon("com/jrefinery/report/resources/SaveAs24.gif")},
{"action.page-setup.name", "Page Setup"},
{"action.page-setup.description", "Page Setup"},
{"action.page-setup.mnemonic", new Integer(KeyEvent.VK_G)},
{"action.page-setup.small-icon",
getIcon("com/jrefinery/report/resources/PageSetup16.gif")},
{"action.page-setup.icon", getIcon("com/jrefinery/report/resources/PageSetup24.gif")},
{"action.print.name", "Print..."},
{"action.print.description", "Print report"},
{"action.print.mnemonic", new Integer(KeyEvent.VK_P)},
{"action.print.accelerator", createMenuKeystroke(KeyEvent.VK_P)},
{"action.print.small-icon", getIcon("com/jrefinery/report/resources/Print16.gif")},
{"action.print.icon", getIcon("com/jrefinery/report/resources/Print24.gif")},
{"action.close.name", "Close"},
{"action.close.description", "Close print preview window"},
{"action.close.mnemonic", new Integer(KeyEvent.VK_C)},
{"action.close.accelerator", createMenuKeystroke(KeyEvent.VK_X)},
{"action.gotopage.name", "Go to page ..."},
{"action.gotopage.description", "View a page directly"},
{"action.gotopage.mnemonic", new Integer(KeyEvent.VK_G)},
{"action.gotopage.accelerator", createMenuKeystroke(KeyEvent.VK_G)},
{"dialog.gotopage.message", "Enter a page number"},
{"dialog.gotopage.title", "Go to page"},
{"action.about.name", "About..."},
{"action.about.description", "Information about the application"},
{"action.about.mnemonic", new Integer(KeyEvent.VK_A)},
{"action.about.small-icon", getIcon("com/jrefinery/report/resources/About16.gif")},
{"action.about.icon", getIcon("com/jrefinery/report/resources/About24.gif")},
{"action.firstpage.name", "Home"},
{"action.firstpage.mnemonic", new Integer(KeyEvent.VK_HOME)},
{"action.firstpage.description", "Switch to the first page"},
{"action.firstpage.small-icon",
getIcon("com/jrefinery/report/resources/FirstPage16.gif")},
{"action.firstpage.icon", getIcon("com/jrefinery/report/resources/FirstPage24.gif")},
{"action.firstpage.accelerator", KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0)},
{"action.back.name", "Back"},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -