Compare commits
53 Commits
jding/TUP-
...
release/8.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5210b033d0 | ||
|
|
e91b347450 | ||
|
|
ea459b8710 | ||
|
|
2ee58ac9d0 | ||
|
|
0e668b3239 | ||
|
|
1fe8bec5cf | ||
|
|
74d5eb4d90 | ||
|
|
12a842a565 | ||
|
|
9419f94c07 | ||
|
|
0beef6b531 | ||
|
|
d19f0dbce7 | ||
|
|
6ff18c0449 | ||
|
|
4c93a1bed0 | ||
|
|
2462a7a792 | ||
|
|
e18ffe5f0f | ||
|
|
b22b9decce | ||
|
|
9a3307bace | ||
|
|
dd5400af61 | ||
|
|
505609aa4b | ||
|
|
99da8e2286 | ||
|
|
239ece2966 | ||
|
|
ce4740ce83 | ||
|
|
7c795f724c | ||
|
|
67784188df | ||
|
|
248a7d74dc | ||
|
|
c09c406c32 | ||
|
|
bd5b8b0f51 | ||
|
|
eb7c195d3e | ||
|
|
33162c8be4 | ||
|
|
7169a3101a | ||
|
|
192e47b6a3 | ||
|
|
28eda4c880 | ||
|
|
309c2ac056 | ||
|
|
64c530b6b4 | ||
|
|
71f93b5165 | ||
|
|
41b50e16c1 | ||
|
|
b7711e1dd5 | ||
|
|
8ed759c0d8 | ||
|
|
3ff40da876 | ||
|
|
da6a983f29 | ||
|
|
2913c80aef | ||
|
|
fa2abaf8f3 | ||
|
|
81e63ecab0 | ||
|
|
3b647c2316 | ||
|
|
4ff0184a49 | ||
|
|
0e37b9632e | ||
|
|
f2a4328037 | ||
|
|
771a1bf810 | ||
|
|
3f7d1a83d9 | ||
|
|
c20078c3d1 | ||
|
|
d13ae7e637 | ||
|
|
6b094dd4fd | ||
|
|
1ebdb18d27 |
BIN
main/plugins/org.talend.common.ui.runtime/icons/moreInfo.png
Normal file
BIN
main/plugins/org.talend.common.ui.runtime/icons/moreInfo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 288 B |
@@ -57,12 +57,17 @@ public interface ColorConstants {
|
||||
|
||||
static Color getTableBackgroundColor() {
|
||||
return ITalendThemeService.getColor(ColorConstants.BUNDLE_ID_COMMON_UI_RUNTIME, ColorConstants.KEY_TABLE_BACKGROUND)
|
||||
.orElse(WHITE_COLOR);
|
||||
.orElse(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
|
||||
}
|
||||
|
||||
static Color getTableForegroundColor() {
|
||||
return ITalendThemeService.getColor(ColorConstants.BUNDLE_ID_COMMON_UI_RUNTIME, ColorConstants.KEY_TABLE_FOREGROUND)
|
||||
.orElse(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
|
||||
.orElse(Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
|
||||
}
|
||||
|
||||
static Color getTableReadOnlyForegroundColor() {
|
||||
return ITalendThemeService.getColor("CONTEXT_TABLE_READONLY_FOREGROUND")
|
||||
.orElse(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.talend.commons.ui.runtime;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.osgi.framework.BundleContext;
|
||||
@@ -29,6 +30,8 @@ public interface ITalendThemeService {
|
||||
|
||||
public static String DEFAULT_PREFERENCE_ID = "org.eclipse.ui.workbench";
|
||||
|
||||
public static String THEME_PREFERENCE_ID = "org.eclipse.e4.ui.css.swt.theme";
|
||||
|
||||
/**
|
||||
* Get color from instance scope preference of default bundleId, which managed by theme; the standard way eclipse
|
||||
* uses
|
||||
@@ -132,6 +135,8 @@ public interface ITalendThemeService {
|
||||
|
||||
void removePropertyChangeListenerFor(String bundleId, IPropertyChangeListener listener);
|
||||
|
||||
IPreferenceStore getThemePreferenceStore();
|
||||
|
||||
static ITalendThemeService get() {
|
||||
try {
|
||||
BundleContext bc = FrameworkUtil.getBundle(ITalendThemeService.class).getBundleContext();
|
||||
|
||||
@@ -40,8 +40,8 @@ public enum EImage implements IImage {
|
||||
READ_ICON("/icons/read_obj.gif"), //$NON-NLS-1$
|
||||
|
||||
QUESTION_ICON("/icons/question.gif"), //$NON-NLS-1$
|
||||
|
||||
HELP_ICON("/icons/help.png"), //$NON-NLS-1$
|
||||
MOREINFO_ICON("/icons/moreInfo.png"), //$NON-NLS-1$
|
||||
|
||||
CREATE_CONNECTION_ICON("/icons/connection.gif"), //$NON-NLS-1$
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<version>2.12.0</version>
|
||||
<version>2.12.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.reload4j</groupId>
|
||||
|
||||
@@ -145,7 +145,30 @@ public class DB2ForZosDataBaseMetadata extends PackageFakeDatabaseMetadata {
|
||||
*/
|
||||
@Override
|
||||
public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
|
||||
return new DB2ForZosResultSet();
|
||||
ResultSet rs = super.getPrimaryKeys(catalog, schema, table);
|
||||
if (rs == null) {
|
||||
rs = new DB2ForZosResultSet();
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.utils.database.FakeDatabaseMetaData#getExportedKeys(java.lang.String, java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException {
|
||||
ResultSet rs = super.getExportedKeys(catalog, schema, table);
|
||||
if (rs == null) {
|
||||
if (this.metaData != null) {
|
||||
rs = this.metaData.getExportedKeys(catalog, schema, table);
|
||||
} else {
|
||||
rs = new DB2ForZosResultSet();
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -174,17 +197,6 @@ public class DB2ForZosDataBaseMetadata extends PackageFakeDatabaseMetadata {
|
||||
return tableResultSet;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.utils.database.FakeDatabaseMetaData#getExportedKeys(java.lang.String, java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException {
|
||||
return new DB2ForZosResultSet();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -18,12 +18,12 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferenceConverter;
|
||||
import org.eclipse.jface.resource.StringConverter;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.talend.commons.ui.runtime.ITalendThemeService;
|
||||
import org.talend.commons.ui.swt.colorstyledtext.scanner.ColoringScanner;
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@ import org.talend.commons.ui.swt.colorstyledtext.scanner.ColoringScanner;
|
||||
*
|
||||
*/
|
||||
public class ColorManager {
|
||||
|
||||
|
||||
public static final RGB DEFAULT_STRING_COLOR = new RGB(0, 0, 0);
|
||||
|
||||
public static final RGB DEFAULT_KEYWORD1_COLOR = new RGB(50, 32, 160);
|
||||
@@ -106,15 +106,19 @@ public class ColorManager {
|
||||
}
|
||||
|
||||
public Color getColor(String colorName) {
|
||||
RGB prefColor = PreferenceConverter.getColor(store, colorName);
|
||||
Color color = null;
|
||||
if (colorMap.containsKey(colorName) && (colorMap.get(colorName)).getRGB().equals(prefColor)) {
|
||||
color = (Color) colorMap.get(colorName);
|
||||
Color prefColor = getThemeColor(colorName);
|
||||
if (colorMap.containsKey(colorName) && (colorMap.get(colorName)).equals(prefColor)) {
|
||||
return colorMap.get(colorName);
|
||||
} else {
|
||||
color = new Color(Display.getDefault(), prefColor);
|
||||
colorMap.put(colorName, color);
|
||||
colorMap.put(colorName, prefColor);
|
||||
}
|
||||
return color;
|
||||
return prefColor;
|
||||
}
|
||||
|
||||
private static Color getThemeColor(String colorName) {
|
||||
Color c = ITalendThemeService.getColor(colorName)
|
||||
.orElse(Display.getDefault().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
|
||||
return c;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
@@ -164,20 +168,20 @@ public class ColorManager {
|
||||
}
|
||||
|
||||
public static void initDefaultColors(IPreferenceStore store) {
|
||||
store.setDefault(NULL_COLOR, StringConverter.asString(DEFAULT_STRING_COLOR));
|
||||
store.setDefault(COMMENT1_COLOR, StringConverter.asString(DEFAULT_COMMENT1_COLOR));
|
||||
store.setDefault(COMMENT2_COLOR, StringConverter.asString(DEFAULT_COMMENT2_COLOR));
|
||||
store.setDefault(LITERAL1_COLOR, StringConverter.asString(DEFAULT_LITERAL1_COLOR));
|
||||
store.setDefault(LITERAL2_COLOR, StringConverter.asString(DEFAULT_LITERAL2_COLOR));
|
||||
store.setDefault(LABEL_COLOR, StringConverter.asString(DEFAULT_LABEL_COLOR));
|
||||
store.setDefault(KEYWORD1_COLOR, StringConverter.asString(DEFAULT_KEYWORD1_COLOR));
|
||||
store.setDefault(KEYWORD2_COLOR, StringConverter.asString(DEFAULT_KEYWORD2_COLOR));
|
||||
store.setDefault(KEYWORD3_COLOR, StringConverter.asString(DEFAULT_KEYWORD3_COLOR));
|
||||
store.setDefault(FUNCTION_COLOR, StringConverter.asString(DEFAULT_FUNCTION_COLOR));
|
||||
store.setDefault(MARKUP_COLOR, StringConverter.asString(DEFAULT_MARKUP_COLOR));
|
||||
store.setDefault(OPERATOR_COLOR, StringConverter.asString(DEFAULT_OPERATOR_COLOR));
|
||||
store.setDefault(DIGIT_COLOR, StringConverter.asString(DEFAULT_DIGIT_COLOR));
|
||||
store.setDefault(INVALID_COLOR, StringConverter.asString(DEFAULT_INVALID_COLOR));
|
||||
store.setDefault(NULL_COLOR, StringConverter.asString(getThemeColor(NULL_COLOR).getRGB()));
|
||||
store.setDefault(COMMENT1_COLOR, StringConverter.asString(getThemeColor(COMMENT1_COLOR).getRGB()));
|
||||
store.setDefault(COMMENT2_COLOR, StringConverter.asString(getThemeColor(COMMENT2_COLOR).getRGB()));
|
||||
store.setDefault(LITERAL1_COLOR, StringConverter.asString(getThemeColor(LITERAL1_COLOR).getRGB()));
|
||||
store.setDefault(LITERAL2_COLOR, StringConverter.asString(getThemeColor(LITERAL2_COLOR).getRGB()));
|
||||
store.setDefault(LABEL_COLOR, StringConverter.asString(getThemeColor(LABEL_COLOR).getRGB()));
|
||||
store.setDefault(KEYWORD1_COLOR, StringConverter.asString(getThemeColor(KEYWORD1_COLOR).getRGB()));
|
||||
store.setDefault(KEYWORD2_COLOR, StringConverter.asString(getThemeColor(KEYWORD2_COLOR).getRGB()));
|
||||
store.setDefault(KEYWORD3_COLOR, StringConverter.asString(getThemeColor(KEYWORD3_COLOR).getRGB()));
|
||||
store.setDefault(FUNCTION_COLOR, StringConverter.asString(getThemeColor(FUNCTION_COLOR).getRGB()));
|
||||
store.setDefault(MARKUP_COLOR, StringConverter.asString(getThemeColor(MARKUP_COLOR).getRGB()));
|
||||
store.setDefault(OPERATOR_COLOR, StringConverter.asString(getThemeColor(OPERATOR_COLOR).getRGB()));
|
||||
store.setDefault(DIGIT_COLOR, StringConverter.asString(getThemeColor(DIGIT_COLOR).getRGB()));
|
||||
store.setDefault(INVALID_COLOR, StringConverter.asString(getThemeColor(INVALID_COLOR).getRGB()));
|
||||
|
||||
String bold = BOLD_SUFFIX;
|
||||
store.setDefault(COMMENT1_COLOR + bold, false);
|
||||
|
||||
@@ -1,368 +1,384 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.commons.ui.swt.colorstyledtext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.text.rules.IToken;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.ExtendedModifyEvent;
|
||||
import org.eclipse.swt.custom.ExtendedModifyListener;
|
||||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.eclipse.ui.ISharedImages;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.talend.commons.runtime.xml.XmlUtil;
|
||||
import org.talend.commons.ui.runtime.i18n.Messages;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.ui.swt.colorstyledtext.jedit.Mode;
|
||||
import org.talend.commons.ui.swt.colorstyledtext.jedit.Modes;
|
||||
import org.talend.commons.ui.swt.colorstyledtext.rules.CToken;
|
||||
import org.talend.commons.ui.swt.colorstyledtext.scanner.ColoringScanner;
|
||||
import org.talend.commons.utils.threading.ExecutionLimiter;
|
||||
|
||||
/**
|
||||
* This component is an adaptation of a Color Editor for a StyledText.
|
||||
*
|
||||
* The original editor can be found on http://www.gstaff.org/colorEditor/ <br/>
|
||||
*
|
||||
* <b>How to use it, example :</b> <br/>
|
||||
* ColorStyledText text = new ColorStyledText(parent, SWT.H_SCROLL | SWT.V_SCROLL,
|
||||
* CorePlugin.getDefault().getPreferenceStore(), ECodeLanguage.PERL.getName());</i> <br/>
|
||||
* <br/>
|
||||
*
|
||||
* $Id: ColorStyledText.java 7183 2007-11-23 11:03:36Z amaumont $
|
||||
*
|
||||
*/
|
||||
public class ColorStyledText extends StyledText {
|
||||
|
||||
private final static int MAXIMUM_CHARACTERS_BEFORE_USE_TIMER = 1000;
|
||||
|
||||
private final ColorManager colorManager;
|
||||
|
||||
private final ColoringScanner scanner;
|
||||
|
||||
private final String languageMode;
|
||||
|
||||
private final MenuItem pasteItem;
|
||||
|
||||
private boolean coloring = true;
|
||||
|
||||
private UndoRedoManager undoRedoManager;
|
||||
|
||||
public ColorStyledText(Composite parent, int style, IPreferenceStore store, String languageMode) {
|
||||
super(parent, style);
|
||||
this.languageMode = languageMode;
|
||||
this.colorManager = new ColorManager(store);
|
||||
|
||||
/*
|
||||
* set the Shortcuts of the undo/redo
|
||||
*/
|
||||
this.setKeyBinding('Z' | SWT.CTRL, ActionCode.UNDO);
|
||||
this.setKeyBinding('Y' | SWT.CTRL, ActionCode.REDO);
|
||||
UndoRedoManager undoManager = new UndoRedoManager(50);
|
||||
undoManager.connect(this);
|
||||
this.setUndoManager(undoManager);
|
||||
|
||||
ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
|
||||
Menu popupMenu = new Menu(this);
|
||||
|
||||
MenuItem redoItem = new MenuItem(popupMenu, SWT.PUSH);
|
||||
redoItem.setText(Messages.getString("ColorStyledText.RedoItem.Text")); //$NON-NLS-1$
|
||||
redoItem.addListener(SWT.Selection, new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
redo();
|
||||
}
|
||||
});
|
||||
|
||||
MenuItem undoItem = new MenuItem(popupMenu, SWT.PUSH);
|
||||
undoItem.setText(Messages.getString("ColorStyledText.UndoItem.Text")); //$NON-NLS-1$
|
||||
undoItem.addListener(SWT.Selection, new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
undo();
|
||||
}
|
||||
});
|
||||
|
||||
Image image = ImageProvider.getImage(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
|
||||
MenuItem copyItem = new MenuItem(popupMenu, SWT.PUSH);
|
||||
copyItem.setText(Messages.getString("ColorStyledText.CopyItem.Text")); //$NON-NLS-1$
|
||||
copyItem.setImage(image);
|
||||
copyItem.addListener(SWT.Selection, new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
copy();
|
||||
}
|
||||
});
|
||||
|
||||
image = ImageProvider.getImage(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
|
||||
pasteItem = new MenuItem(popupMenu, SWT.PUSH);
|
||||
pasteItem.setText(Messages.getString("ColorStyledText.PasteItem.Text")); //$NON-NLS-1$
|
||||
pasteItem.setData(this);
|
||||
pasteItem.setImage(image);
|
||||
pasteItem.addListener(SWT.Selection, new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
paste();
|
||||
}
|
||||
});
|
||||
pasteItem.setEnabled(getEditable());
|
||||
|
||||
this.setMenu(popupMenu);
|
||||
MenuItem selectAllItem = new MenuItem(popupMenu, SWT.PUSH);
|
||||
selectAllItem.setText(Messages.getString("ColorStyledText.SelectAllItem.Text")); //$NON-NLS-1$
|
||||
selectAllItem.addListener(SWT.Selection, new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
selectAll();
|
||||
}
|
||||
});
|
||||
this.setMenu(popupMenu);
|
||||
|
||||
Listener selectAllListener = new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
if (event.character == '\u0001') { // CTRL + A
|
||||
selectAll();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
addListener(SWT.KeyDown, selectAllListener);
|
||||
|
||||
Mode mode = Modes.getMode(languageMode + XmlUtil.FILE_XML_SUFFIX);
|
||||
scanner = new ColoringScanner(mode, colorManager);
|
||||
|
||||
addExtendedModifyListener(modifyListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC qli Comment method "invokeAction".
|
||||
*
|
||||
* @param action
|
||||
*
|
||||
* */
|
||||
public void invokeAction(int action) {
|
||||
super.invokeAction(action);
|
||||
|
||||
switch (action) {
|
||||
case ActionCode.UNDO:
|
||||
undo(); // ctrl+Z
|
||||
break;
|
||||
case ActionCode.REDO:
|
||||
redo(); // ctrl+Y
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for undoRedoManager.
|
||||
*
|
||||
* @return the undoRedoManager
|
||||
*/
|
||||
public UndoRedoManager getUndoManager() {
|
||||
return this.undoRedoManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the undoRedoManager.
|
||||
*
|
||||
* @param undoRedoManager the undoRedoManager to set
|
||||
*/
|
||||
public void setUndoManager(UndoRedoManager undoRedoManager) {
|
||||
this.undoRedoManager = undoRedoManager;
|
||||
}
|
||||
|
||||
public static class ActionCode {
|
||||
|
||||
public static final int UNDO = Integer.MAX_VALUE;
|
||||
|
||||
public static final int REDO = UNDO - 1;
|
||||
|
||||
}
|
||||
|
||||
private void undo() {
|
||||
if (undoRedoManager != null) {
|
||||
undoRedoManager.undo();
|
||||
}
|
||||
}
|
||||
|
||||
private void redo() {
|
||||
if (undoRedoManager != null) {
|
||||
undoRedoManager.redo();
|
||||
}
|
||||
}
|
||||
|
||||
protected void colorize(final ColoringScanner scanner) {
|
||||
final ArrayList<StyleRange> styles = new ArrayList<StyleRange>();
|
||||
if (this.coloring) {
|
||||
IToken token;
|
||||
if (this.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
scanner.parse(this.getText().replaceAll("\"", " ").replaceAll("'", " ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
|
||||
do {
|
||||
token = scanner.nextToken();
|
||||
if (!token.isEOF()) {
|
||||
if (token instanceof CToken) {
|
||||
CToken ctoken = (CToken) token;
|
||||
StyleRange styleRange;
|
||||
styleRange = new StyleRange();
|
||||
styleRange.start = scanner.getTokenOffset();
|
||||
styleRange.length = scanner.getTokenLength();
|
||||
if (ctoken.getType() == null) {
|
||||
styleRange.fontStyle = colorManager.getStyleFor(ctoken.getColor());
|
||||
styleRange.foreground = colorManager.getColor(ctoken.getColor());
|
||||
} else {
|
||||
styleRange.fontStyle = colorManager.getStyleForType(ctoken.getColor());
|
||||
styleRange.foreground = colorManager.getColorForType(ctoken.getColor());
|
||||
}
|
||||
styles.add(styleRange);
|
||||
}
|
||||
}
|
||||
} while (!token.isEOF());
|
||||
setStyles(styles);
|
||||
} else {
|
||||
StyleRange styleRange = new StyleRange();
|
||||
styles.add(styleRange);
|
||||
styleRange.start = 0;
|
||||
styleRange.length = this.getText().getBytes().length;
|
||||
styleRange.foreground = null;
|
||||
setStyles(styles);
|
||||
}
|
||||
}
|
||||
|
||||
public void setStyles(final ArrayList<StyleRange> styles) {
|
||||
if (ColorStyledText.this.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
int countChars = getCharCount();
|
||||
|
||||
for (int i = 0; i < styles.size(); i++) {
|
||||
StyleRange styleRange = styles.get(i);
|
||||
// System.out.println("styleRange.start=" + styleRange.start);
|
||||
// System.out.println("styleRange.length=" + styleRange.length);
|
||||
if (!(0 <= styleRange.start && styleRange.start + styleRange.length <= countChars)) {
|
||||
continue;
|
||||
}
|
||||
setStyleRange(styleRange);
|
||||
}
|
||||
}
|
||||
|
||||
ExtendedModifyListener modifyListener = new ExtendedModifyListener() {
|
||||
|
||||
public void modifyText(ExtendedModifyEvent event) {
|
||||
if (ColorStyledText.this.getCharCount() > MAXIMUM_CHARACTERS_BEFORE_USE_TIMER) {
|
||||
colorizeLimiter.resetTimer();
|
||||
colorizeLimiter.startIfExecutable(true, null);
|
||||
} else {
|
||||
getDisplay().asyncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
colorize(scanner);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public ColorManager getColorManager() {
|
||||
return this.colorManager;
|
||||
}
|
||||
|
||||
public String getLanguageMode() {
|
||||
return this.languageMode;
|
||||
}
|
||||
|
||||
public ColoringScanner getScanner() {
|
||||
return this.scanner;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.swt.custom.StyledText#setEditable(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setEditable(boolean editable) {
|
||||
super.setEditable(editable);
|
||||
if (pasteItem != null) {
|
||||
pasteItem.setEnabled(editable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for coloring.
|
||||
*
|
||||
* @return the coloring
|
||||
*/
|
||||
public boolean isColoring() {
|
||||
return this.coloring;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the coloring.
|
||||
*
|
||||
* @param coloring the coloring to set
|
||||
*/
|
||||
public void setColoring(boolean coloring) {
|
||||
boolean wasDifferent = this.coloring != coloring;
|
||||
this.coloring = coloring;
|
||||
if (!coloring) {
|
||||
removeExtendedModifyListener(modifyListener);
|
||||
} else if (wasDifferent) {
|
||||
colorizeLimiter.resetTimer();
|
||||
colorizeLimiter.startIfExecutable(true, null);
|
||||
addExtendedModifyListener(modifyListener);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.swt.widgets.Widget#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
colorManager.dispose();
|
||||
}
|
||||
|
||||
private final ExecutionLimiter colorizeLimiter = new ExecutionLimiter(1000, true) {
|
||||
|
||||
@Override
|
||||
public void execute(final boolean isFinalExecution, Object data) {
|
||||
if (!isDisposed()) {
|
||||
getDisplay().asyncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
colorize(scanner);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.commons.ui.swt.colorstyledtext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.text.rules.IToken;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.ExtendedModifyEvent;
|
||||
import org.eclipse.swt.custom.ExtendedModifyListener;
|
||||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.eclipse.ui.ISharedImages;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.talend.commons.runtime.xml.XmlUtil;
|
||||
import org.talend.commons.ui.runtime.ITalendThemeService;
|
||||
import org.talend.commons.ui.runtime.i18n.Messages;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.ui.swt.colorstyledtext.jedit.Mode;
|
||||
import org.talend.commons.ui.swt.colorstyledtext.jedit.Modes;
|
||||
import org.talend.commons.ui.swt.colorstyledtext.rules.CToken;
|
||||
import org.talend.commons.ui.swt.colorstyledtext.scanner.ColoringScanner;
|
||||
import org.talend.commons.utils.threading.ExecutionLimiter;
|
||||
|
||||
/**
|
||||
* This component is an adaptation of a Color Editor for a StyledText.
|
||||
*
|
||||
* The original editor can be found on http://www.gstaff.org/colorEditor/ <br/>
|
||||
*
|
||||
* <b>How to use it, example :</b> <br/>
|
||||
* ColorStyledText text = new ColorStyledText(parent, SWT.H_SCROLL | SWT.V_SCROLL,
|
||||
* CorePlugin.getDefault().getPreferenceStore(), ECodeLanguage.PERL.getName());</i> <br/>
|
||||
* <br/>
|
||||
*
|
||||
* $Id: ColorStyledText.java 7183 2007-11-23 11:03:36Z amaumont $
|
||||
*
|
||||
*/
|
||||
public class ColorStyledText extends StyledText {
|
||||
|
||||
|
||||
public static final String PREFERENCE_COLOR_FOREGROUND= "ColorStyledText.Color.Foreground"; //$NON-NLS-1$
|
||||
public static final String PREFERENCE_COLOR_BACKGROUND= "ColorStyledText.Color.Background"; //$NON-NLS-1$
|
||||
public static final String PREFERENCE_COLOR_SELECTION_FOREGROUND= "ColorStyledText.Color.SelectionForeground"; //$NON-NLS-1$
|
||||
public static final String PREFERENCE_COLOR_SELECTION_BACKGROUND= "ColorStyledText.Color.SelectionBackground"; //$NON-NLS-1$
|
||||
|
||||
private final static int MAXIMUM_CHARACTERS_BEFORE_USE_TIMER = 1000;
|
||||
|
||||
private final ColorManager colorManager;
|
||||
|
||||
private final ColoringScanner scanner;
|
||||
|
||||
private final String languageMode;
|
||||
|
||||
private final MenuItem pasteItem;
|
||||
|
||||
private boolean coloring = true;
|
||||
|
||||
private UndoRedoManager undoRedoManager;
|
||||
|
||||
public ColorStyledText(Composite parent, int style, IPreferenceStore store, String languageMode) {
|
||||
super(parent, style);
|
||||
this.languageMode = languageMode;
|
||||
this.colorManager = new ColorManager(store);
|
||||
|
||||
/*
|
||||
* set the Shortcuts of the undo/redo
|
||||
*/
|
||||
this.setKeyBinding('Z' | SWT.CTRL, ActionCode.UNDO);
|
||||
this.setKeyBinding('Y' | SWT.CTRL, ActionCode.REDO);
|
||||
UndoRedoManager undoManager = new UndoRedoManager(50);
|
||||
undoManager.connect(this);
|
||||
this.setUndoManager(undoManager);
|
||||
|
||||
ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
|
||||
Menu popupMenu = new Menu(this);
|
||||
|
||||
MenuItem redoItem = new MenuItem(popupMenu, SWT.PUSH);
|
||||
redoItem.setText(Messages.getString("ColorStyledText.RedoItem.Text")); //$NON-NLS-1$
|
||||
redoItem.addListener(SWT.Selection, new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
redo();
|
||||
}
|
||||
});
|
||||
|
||||
MenuItem undoItem = new MenuItem(popupMenu, SWT.PUSH);
|
||||
undoItem.setText(Messages.getString("ColorStyledText.UndoItem.Text")); //$NON-NLS-1$
|
||||
undoItem.addListener(SWT.Selection, new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
undo();
|
||||
}
|
||||
});
|
||||
|
||||
Image image = ImageProvider.getImage(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
|
||||
MenuItem copyItem = new MenuItem(popupMenu, SWT.PUSH);
|
||||
copyItem.setText(Messages.getString("ColorStyledText.CopyItem.Text")); //$NON-NLS-1$
|
||||
copyItem.setImage(image);
|
||||
copyItem.addListener(SWT.Selection, new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
copy();
|
||||
}
|
||||
});
|
||||
|
||||
image = ImageProvider.getImage(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
|
||||
pasteItem = new MenuItem(popupMenu, SWT.PUSH);
|
||||
pasteItem.setText(Messages.getString("ColorStyledText.PasteItem.Text")); //$NON-NLS-1$
|
||||
pasteItem.setData(this);
|
||||
pasteItem.setImage(image);
|
||||
pasteItem.addListener(SWT.Selection, new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
paste();
|
||||
}
|
||||
});
|
||||
pasteItem.setEnabled(getEditable());
|
||||
|
||||
this.setMenu(popupMenu);
|
||||
MenuItem selectAllItem = new MenuItem(popupMenu, SWT.PUSH);
|
||||
selectAllItem.setText(Messages.getString("ColorStyledText.SelectAllItem.Text")); //$NON-NLS-1$
|
||||
selectAllItem.addListener(SWT.Selection, new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
selectAll();
|
||||
}
|
||||
});
|
||||
this.setMenu(popupMenu);
|
||||
|
||||
Listener selectAllListener = new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
if (event.character == '\u0001') { // CTRL + A
|
||||
selectAll();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
addListener(SWT.KeyDown, selectAllListener);
|
||||
|
||||
Mode mode = Modes.getMode(languageMode + XmlUtil.FILE_XML_SUFFIX);
|
||||
scanner = new ColoringScanner(mode, colorManager);
|
||||
|
||||
addExtendedModifyListener(modifyListener);
|
||||
initColorSetting();
|
||||
}
|
||||
|
||||
|
||||
protected void initColorSetting() {
|
||||
this.setForeground(ITalendThemeService.getColor(PREFERENCE_COLOR_FOREGROUND).orElse(null));
|
||||
this.setBackground(ITalendThemeService.getColor(PREFERENCE_COLOR_BACKGROUND).orElse(null));
|
||||
this.setSelectionBackground(ITalendThemeService.getColor(PREFERENCE_COLOR_SELECTION_BACKGROUND).orElse(null));
|
||||
this.setSelectionForeground(ITalendThemeService.getColor(PREFERENCE_COLOR_SELECTION_FOREGROUND).orElse(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC qli Comment method "invokeAction".
|
||||
*
|
||||
* @param action
|
||||
*
|
||||
* */
|
||||
public void invokeAction(int action) {
|
||||
super.invokeAction(action);
|
||||
|
||||
switch (action) {
|
||||
case ActionCode.UNDO:
|
||||
undo(); // ctrl+Z
|
||||
break;
|
||||
case ActionCode.REDO:
|
||||
redo(); // ctrl+Y
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for undoRedoManager.
|
||||
*
|
||||
* @return the undoRedoManager
|
||||
*/
|
||||
public UndoRedoManager getUndoManager() {
|
||||
return this.undoRedoManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the undoRedoManager.
|
||||
*
|
||||
* @param undoRedoManager the undoRedoManager to set
|
||||
*/
|
||||
public void setUndoManager(UndoRedoManager undoRedoManager) {
|
||||
this.undoRedoManager = undoRedoManager;
|
||||
}
|
||||
|
||||
public static class ActionCode {
|
||||
|
||||
public static final int UNDO = Integer.MAX_VALUE;
|
||||
|
||||
public static final int REDO = UNDO - 1;
|
||||
|
||||
}
|
||||
|
||||
private void undo() {
|
||||
if (undoRedoManager != null) {
|
||||
undoRedoManager.undo();
|
||||
}
|
||||
}
|
||||
|
||||
private void redo() {
|
||||
if (undoRedoManager != null) {
|
||||
undoRedoManager.redo();
|
||||
}
|
||||
}
|
||||
|
||||
protected void colorize(final ColoringScanner scanner) {
|
||||
final ArrayList<StyleRange> styles = new ArrayList<StyleRange>();
|
||||
if (this.coloring) {
|
||||
IToken token;
|
||||
if (this.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
scanner.parse(this.getText().replaceAll("\"", " ").replaceAll("'", " ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
|
||||
do {
|
||||
token = scanner.nextToken();
|
||||
if (!token.isEOF()) {
|
||||
if (token instanceof CToken) {
|
||||
CToken ctoken = (CToken) token;
|
||||
StyleRange styleRange;
|
||||
styleRange = new StyleRange();
|
||||
styleRange.start = scanner.getTokenOffset();
|
||||
styleRange.length = scanner.getTokenLength();
|
||||
if (ctoken.getType() == null) {
|
||||
styleRange.fontStyle = colorManager.getStyleFor(ctoken.getColor());
|
||||
styleRange.foreground = colorManager.getColor(ctoken.getColor());
|
||||
} else {
|
||||
styleRange.fontStyle = colorManager.getStyleForType(ctoken.getColor());
|
||||
styleRange.foreground = colorManager.getColorForType(ctoken.getColor());
|
||||
}
|
||||
styles.add(styleRange);
|
||||
}
|
||||
}
|
||||
} while (!token.isEOF());
|
||||
setStyles(styles);
|
||||
} else {
|
||||
StyleRange styleRange = new StyleRange();
|
||||
styles.add(styleRange);
|
||||
styleRange.start = 0;
|
||||
styleRange.length = this.getText().getBytes().length;
|
||||
styleRange.foreground = null;
|
||||
setStyles(styles);
|
||||
}
|
||||
}
|
||||
|
||||
public void setStyles(final ArrayList<StyleRange> styles) {
|
||||
if (ColorStyledText.this.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
int countChars = getCharCount();
|
||||
|
||||
for (int i = 0; i < styles.size(); i++) {
|
||||
StyleRange styleRange = styles.get(i);
|
||||
// System.out.println("styleRange.start=" + styleRange.start);
|
||||
// System.out.println("styleRange.length=" + styleRange.length);
|
||||
if (!(0 <= styleRange.start && styleRange.start + styleRange.length <= countChars)) {
|
||||
continue;
|
||||
}
|
||||
setStyleRange(styleRange);
|
||||
}
|
||||
}
|
||||
|
||||
ExtendedModifyListener modifyListener = new ExtendedModifyListener() {
|
||||
|
||||
public void modifyText(ExtendedModifyEvent event) {
|
||||
if (ColorStyledText.this.getCharCount() > MAXIMUM_CHARACTERS_BEFORE_USE_TIMER) {
|
||||
colorizeLimiter.resetTimer();
|
||||
colorizeLimiter.startIfExecutable(true, null);
|
||||
} else {
|
||||
getDisplay().asyncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
colorize(scanner);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public ColorManager getColorManager() {
|
||||
return this.colorManager;
|
||||
}
|
||||
|
||||
public String getLanguageMode() {
|
||||
return this.languageMode;
|
||||
}
|
||||
|
||||
public ColoringScanner getScanner() {
|
||||
return this.scanner;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.swt.custom.StyledText#setEditable(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setEditable(boolean editable) {
|
||||
super.setEditable(editable);
|
||||
if (pasteItem != null) {
|
||||
pasteItem.setEnabled(editable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for coloring.
|
||||
*
|
||||
* @return the coloring
|
||||
*/
|
||||
public boolean isColoring() {
|
||||
return this.coloring;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the coloring.
|
||||
*
|
||||
* @param coloring the coloring to set
|
||||
*/
|
||||
public void setColoring(boolean coloring) {
|
||||
boolean wasDifferent = this.coloring != coloring;
|
||||
this.coloring = coloring;
|
||||
if (!coloring) {
|
||||
removeExtendedModifyListener(modifyListener);
|
||||
} else if (wasDifferent) {
|
||||
colorizeLimiter.resetTimer();
|
||||
colorizeLimiter.startIfExecutable(true, null);
|
||||
addExtendedModifyListener(modifyListener);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.swt.widgets.Widget#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
colorManager.dispose();
|
||||
}
|
||||
|
||||
private final ExecutionLimiter colorizeLimiter = new ExecutionLimiter(1000, true) {
|
||||
|
||||
@Override
|
||||
public void execute(final boolean isFinalExecution, Object data) {
|
||||
if (!isDisposed()) {
|
||||
getDisplay().asyncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
colorize(scanner);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -16,8 +16,10 @@ import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.ICellEditorListener;
|
||||
import org.eclipse.jface.viewers.TextCellEditor;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.talend.commons.ui.runtime.ColorConstants;
|
||||
import org.talend.commons.ui.runtime.i18n.Messages;
|
||||
import org.talend.commons.ui.runtime.swt.tableviewer.data.ModifiedObjectInfo;
|
||||
import org.talend.commons.ui.runtime.thread.AsynchronousThreading;
|
||||
@@ -39,6 +41,8 @@ public abstract class DialogErrorForCellEditorListener implements ICellEditorLis
|
||||
protected TableViewerCreatorColumn column;
|
||||
|
||||
protected TableViewerCreator tableViewerCreator;
|
||||
|
||||
private Color tableBackground = ColorConstants.getTableBackgroundColor();
|
||||
|
||||
/**
|
||||
* DOC amaumont CellEditorListener constructor comment.
|
||||
@@ -89,7 +93,7 @@ public abstract class DialogErrorForCellEditorListener implements ICellEditorLis
|
||||
final String errorMessage = validateValue(newValue, beanPosition);
|
||||
if (errorMessage == null) {
|
||||
newValidValueTyped(beanPosition, lastValidValue, newValue, state);
|
||||
text.setBackground(text.getDisplay().getSystemColor(SWT.COLOR_WHITE));
|
||||
text.setBackground(tableBackground);
|
||||
lastValidValue = newValue;
|
||||
} else {
|
||||
text.setBackground(text.getDisplay().getSystemColor(SWT.COLOR_RED));
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.talend.commons.ui.gmf.util.DisplayUtils;
|
||||
import org.talend.commons.ui.runtime.ITalendThemeService;
|
||||
|
||||
/**
|
||||
* Figure managing some simple HTML styles. <br/>
|
||||
@@ -77,6 +78,8 @@ public class SimpleHtmlFigure extends Figure {
|
||||
private static Font boldFont = null;
|
||||
|
||||
private static Font boldItalicFont = null;
|
||||
|
||||
private static final Color DEFAULT_LABEL_COLOR = ITalendThemeService.getColor("NODE_FIGURE_LABEL_FORCEGROUND").orElse(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
|
||||
|
||||
/**
|
||||
* Constructs a new SimpleHtmlFigure.
|
||||
@@ -262,6 +265,8 @@ public class SimpleHtmlFigure extends Figure {
|
||||
label.setFont(fontToUse);
|
||||
if (colorStack.size() > 0) {
|
||||
label.setForegroundColor(colorStack.get(colorStack.size() - 1));
|
||||
} else {
|
||||
label.setForegroundColor(DEFAULT_LABEL_COLOR); // Set label default foreground color
|
||||
}
|
||||
horizContainer.add(label);
|
||||
}
|
||||
|
||||
@@ -175,6 +175,7 @@ ProjectRepositoryNode.sapBWDataStoreObject=SAP DSO
|
||||
ProjectRepositoryNode.sapBWInfoCube=SAP InfoCube
|
||||
ProjectRepositoryNode.sapBWInfoObject=SAP InfoObject
|
||||
ProjectRepositoryNode.sapContentExtractor=SAP BI Content Extractor
|
||||
ProjectRepositoryNode.sapCDSView=SAP CDS View
|
||||
RepositoryDropAdapter_copyingItems=Copying items...
|
||||
RepositoryDropAdapter_errorMsg=This directory contains the locked item,it can not be moved now
|
||||
RepositoryDropAdapter_lockedByOthers=This item is locked by other users, it can not be moved now.
|
||||
|
||||
@@ -102,6 +102,7 @@ import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.cwm.helper.SAPBWTableHelper;
|
||||
import org.talend.cwm.helper.SubItemHelper;
|
||||
import org.talend.cwm.helper.TableHelper;
|
||||
import org.talend.cwm.helper.TaggedValueHelper;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.BinRepositoryNode;
|
||||
@@ -1751,6 +1752,9 @@ public class ProjectRepositoryNode extends RepositoryNode implements IProjectRep
|
||||
|
||||
// 10. BW Business Content Extractor:
|
||||
createSAPContentExtractorNodes(repObj, metadataConnection, node, validationRules);
|
||||
|
||||
// 11. CDS views:
|
||||
createSAPCDSViewNodes(repObj, metadataConnection, node, validationRules);
|
||||
} else if (metadataConnection instanceof SalesforceSchemaConnection) {
|
||||
createSalesforceModuleNodes(repObj, metadataConnection, node, validationRules);
|
||||
} else {
|
||||
@@ -1784,7 +1788,9 @@ public class ProjectRepositoryNode extends RepositoryNode implements IProjectRep
|
||||
for (MetadataTable tablesWithOrder : tablesWithOrders) {
|
||||
EMap<String, String> properties = tablesWithOrder.getAdditionalProperties();
|
||||
String partitionKey = properties.get(EProperties.CONTENT_TYPE.name());
|
||||
if (!ERepositoryObjectType.METADATA_SAP_CONTENT_EXTRACTOR.name().equals(partitionKey)) {
|
||||
String cdsType = TaggedValueHelper.getValueString(EProperties.CONTENT_TYPE.name(), tablesWithOrder);
|
||||
if (!ERepositoryObjectType.METADATA_SAP_CONTENT_EXTRACTOR.name().equals(partitionKey)
|
||||
&& !ERepositoryObjectType.METADATA_SAP_CDS_VIEW.name().equals(cdsType)) {
|
||||
tables.add(tablesWithOrder);
|
||||
}
|
||||
}
|
||||
@@ -1967,6 +1973,32 @@ public class ProjectRepositoryNode extends RepositoryNode implements IProjectRep
|
||||
createTables(tableContainer, repObj, tables, ERepositoryObjectType.METADATA_CON_TABLE, validationRules);
|
||||
}
|
||||
|
||||
private void createSAPCDSViewNodes(IRepositoryViewObject repObj, Connection metadataConnection, RepositoryNode node,
|
||||
List<IRepositoryViewObject> validationRules) {
|
||||
StableRepositoryNode tableContainer = new StableRepositoryNode(node,
|
||||
Messages.getString("ProjectRepositoryNode.sapCDSView"), ECoreImage.FOLDER_CLOSE_ICON); //$NON-NLS-1$
|
||||
tableContainer.setChildrenObjectType(ERepositoryObjectType.METADATA_CON_TABLE);
|
||||
tableContainer.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_SAP_CDS_VIEW);
|
||||
IRepositoryNode cacheNode = nodeCache.getCache(tableContainer);
|
||||
if (cacheNode != null && cacheNode instanceof StableRepositoryNode) {
|
||||
tableContainer = (StableRepositoryNode) cacheNode;
|
||||
tableContainer.getChildren().clear();
|
||||
} else {
|
||||
nodeCache.addCache(tableContainer, true);
|
||||
}
|
||||
|
||||
node.getChildren().add(tableContainer);
|
||||
List<MetadataTable> tablesWithOrders = ConnectionHelper.getTablesWithOrders(metadataConnection);
|
||||
EList<MetadataTable> tables = new BasicEList<>();
|
||||
for (MetadataTable tablesWithOrder : tablesWithOrders) {
|
||||
String cdsType = TaggedValueHelper.getValueString(EProperties.CONTENT_TYPE.name(), tablesWithOrder);
|
||||
if (ERepositoryObjectType.METADATA_SAP_CDS_VIEW.name().equals(cdsType)) {
|
||||
tables.add(tablesWithOrder);
|
||||
}
|
||||
}
|
||||
createTables(tableContainer, repObj, tables, ERepositoryObjectType.METADATA_CON_TABLE, validationRules);
|
||||
}
|
||||
|
||||
private void createSalesforceModuleNodes(IRepositoryViewObject rebObj, Connection metadataConnection,
|
||||
RepositoryNode connectionNode, List<IRepositoryViewObject> validationRules) {
|
||||
EList modules = ((SalesforceSchemaConnection) metadataConnection).getModules();
|
||||
|
||||
@@ -54,9 +54,7 @@ import org.eclipse.jface.dialogs.InputDialog;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.osgi.internal.serviceregistry.ServiceReferenceImpl;
|
||||
import org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.navigator.CommonNavigator;
|
||||
import org.eclipse.ui.navigator.CommonViewer;
|
||||
@@ -447,12 +445,10 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
if (currentShell == null) {
|
||||
currentShell = DisplayUtils.getDefaultShell(false);
|
||||
}
|
||||
MessageBox box = new MessageBox(currentShell, SWT.ICON_WARNING | SWT.OK | SWT.CANCEL);
|
||||
box.setText(Messages.getString("ProxyRepositoryFactory.JobNameErroe")); //$NON-NLS-1$
|
||||
box.setMessage(Messages.getString("ProxyRepositoryFactory.Label") + " " + name + " " + Messages.getString("ProxyRepositoryFactory.ReplaceJob")); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
|
||||
|
||||
if (box.open() == SWT.OK) {
|
||||
|
||||
if (MessageDialog.openQuestion(currentShell,
|
||||
Messages.getString("ProxyRepositoryFactory.JobNameErroe"), //$NON-NLS-1$
|
||||
Messages.getString("ProxyRepositoryFactory.Label") + " " + name + " " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ Messages.getString("ProxyRepositoryFactory.ReplaceJob"))) { //$NON-NLS-1$
|
||||
ok[0] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.talend.core.model.utils.CloneConnectionUtils;
|
||||
import org.talend.core.model.utils.ContextParameterUtils;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.cwm.helper.StudioEncryptionHelper;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.model.bridge.ReponsitoryContextBridge;
|
||||
|
||||
@@ -67,6 +68,7 @@ public class StandaloneConnectionContextUtils {
|
||||
String server = getOriginalValue(contextProperties, dbConn.getServerName());
|
||||
String username = getOriginalValue(contextProperties, dbConn.getUsername());
|
||||
String password = getOriginalValue(contextProperties, dbConn.getRawPassword());
|
||||
String originEncryptedPassword = getOriginalValue(contextProperties, dbConn.getPassword());
|
||||
String port = getOriginalValue(contextProperties, dbConn.getPort());
|
||||
String sidOrDatabase = getOriginalValue(contextProperties, dbConn.getSID());
|
||||
String datasource = getOriginalValue(contextProperties, dbConn.getDatasourceName());
|
||||
@@ -87,6 +89,8 @@ public class StandaloneConnectionContextUtils {
|
||||
cloneConn.setDatasourceName(datasource);
|
||||
cloneConn.setDBRootPath(dbRootPath);
|
||||
cloneConn.setFileFieldName(filePath);
|
||||
//To avoid encrypt the same value
|
||||
cloneConn.setPassword(originEncryptedPassword);
|
||||
cloneConn.setRawPassword(password); // the password is raw.
|
||||
cloneConn.setPort(port);
|
||||
cloneConn.setUiSchema(schemaOracle);
|
||||
|
||||
@@ -52,6 +52,7 @@ public enum EDatabase4DriverClassName {
|
||||
MYSQL8(EDatabaseTypeName.MYSQL, "com.mysql.cj.jdbc.Driver"), //$NON-NLS-1$
|
||||
MARIADB(EDatabaseTypeName.MYSQL, "org.mariadb.jdbc.Driver"), //$NON-NLS-1$
|
||||
AMAZON_AURORA(EDatabaseTypeName.AMAZON_AURORA, "org.gjt.mm.mysql.Driver"), //$NON-NLS-1$
|
||||
AMAZON_AURORA_3(EDatabaseTypeName.AMAZON_AURORA, "com.mysql.cj.jdbc.Driver"), //$NON-NLS-1$
|
||||
NETEZZA(EDatabaseTypeName.NETEZZA, "org.netezza.Driver"), //$NON-NLS-1$
|
||||
|
||||
ORACLEFORSID(EDatabaseTypeName.ORACLEFORSID, "oracle.jdbc.OracleDriver", "oracle.jdbc.driver.OracleDriver"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
@@ -252,6 +252,8 @@ public class ConnParameterKeys {
|
||||
|
||||
public static final String CONN_PARA_KEY_EXECUTOR_MEMORY = "CONN_PARA_KEY_EXECUTOR_MEMORY"; //$NON-NLS-1$
|
||||
|
||||
public static final String CONN_PARA_KEY_EXECUTOR_CORES = "CONN_PARA_KEY_EXECUTOR_CORES";
|
||||
|
||||
public static final String CONN_PARA_KEY_TUNING_PROPERTIES = "CONN_PARA_KEY_TUNING_PROPERTIES"; //$NON-NLS-1$
|
||||
|
||||
/******************************************/
|
||||
|
||||
@@ -69,7 +69,7 @@ public enum EDatabaseVersion4Drivers {
|
||||
"SAS 9.2", "SAS_9.2", new String[] { "sas.core.jar", "sas.security.sspi.jar", "sas.svc.connection.jar", "reload4j-1.2.22.jar" })), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
SAPHana(new DbVersion4Drivers(EDatabaseTypeName.SAPHana, "HDB 1.0", "HDB_1_0", "ngdbc.jar")), //$NON-NLS-1$
|
||||
// MYSQL, add for 9594
|
||||
MYSQL_8(new DbVersion4Drivers(EDatabaseTypeName.MYSQL, "MySQL 8", "MYSQL_8", "mysql-connector-java-8.0.18.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
MYSQL_8(new DbVersion4Drivers(EDatabaseTypeName.MYSQL, "MySQL 8", "MYSQL_8", "mysql-connector-j-8.0.33.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
MYSQL_5(new DbVersion4Drivers(EDatabaseTypeName.MYSQL, "MySQL 5", "MYSQL_5", "mysql-connector-java-5.1.49.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
MARIADB(new DbVersion4Drivers(EDatabaseTypeName.MYSQL, "MariaDB", "MARIADB", "mariadb-java-client-2.5.3.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
// add for 9594
|
||||
@@ -81,7 +81,7 @@ public enum EDatabaseVersion4Drivers {
|
||||
new String[] { "mssql-jdbc.jar", "slf4j-api-1.7.34.jar", "slf4j-reload4j-1.7.34.jar", "msal4j-1.11.0.jar", //$NON-NLS-1$
|
||||
"oauth2-oidc-sdk-9.7.jar", "reload4j-1.2.22.jar", "jackson-core-2.13.4.jar",
|
||||
"jackson-databind-2.13.4.2.jar", "jackson-annotations-2.13.4.jar", "jcip-annotations-1.0-1.jar",
|
||||
"json-smart-2.4.7.jar", "nimbus-jose-jwt-9.22.jar", "accessors-smart-2.4.7.jar", "asm-9.1.jar",
|
||||
"json-smart-2.4.9.jar", "nimbus-jose-jwt-9.22.jar", "accessors-smart-2.4.9.jar", "asm-9.5.jar",
|
||||
"content-type-2.1.jar", "lang-tag-1.5.jar" })),
|
||||
|
||||
VERTICA_9(new DbVersion4Drivers(EDatabaseTypeName.VERTICA, "VERTICA 9.X", "VERTICA_9_0", "vertica-jdbc-9.3.1-0.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
@@ -156,7 +156,10 @@ public enum EDatabaseVersion4Drivers {
|
||||
"aws-java-sdk-redshift-internal-1.12.x.jar", "aws-java-sdk-core-1.12.315.jar", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"aws-java-sdk-sts-1.12.315.jar", "aws-java-sdk-redshift-1.12.315.jar", "jmespath-java-1.12.315.jar" })), //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
|
||||
|
||||
AMAZON_AURORA(new DbVersion4Drivers(EDatabaseTypeName.AMAZON_AURORA, "mysql-connector-java-5.1.49.jar")); //$NON-NLS-1$
|
||||
AMAZON_AURORA(new DbVersion4Drivers(EDatabaseTypeName.AMAZON_AURORA, "MySQL 5", "MYSQL_5", //$NON-NLS-1$
|
||||
"mysql-connector-java-5.1.49.jar")),
|
||||
AMAZON_AURORA_3(new DbVersion4Drivers(EDatabaseTypeName.AMAZON_AURORA, "MySQL 8", "MYSQL_8", //$NON-NLS-1$
|
||||
"mysql-connector-j-8.0.33.jar"));
|
||||
|
||||
private DbVersion4Drivers dbVersionBean;
|
||||
|
||||
|
||||
@@ -15,8 +15,10 @@ package org.talend.core.hadoop;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.common.util.EMap;
|
||||
import org.talend.commons.exception.CommonExceptionHandler;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
@@ -25,6 +27,9 @@ import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.runtime.hd.IDynamicDistributionManager;
|
||||
import org.talend.core.runtime.i18n.Messages;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
|
||||
|
||||
/**
|
||||
* created by cmeng on Jul 20, 2015 Detailled comment
|
||||
@@ -145,4 +150,58 @@ public class BigDataBasicUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static String getDistributionByVersion(String version) {
|
||||
if (StringUtils.isEmpty(version))
|
||||
return null;
|
||||
if (version.startsWith("EMR")) {
|
||||
return "AMAZON_EMR";
|
||||
} else if (version.equals("SYNAPSE")) {
|
||||
return "AZURE_SYNAPSE";
|
||||
} else if (version.contains("CDH") || version.contains("CDP")) {
|
||||
return "CLOUDERA";
|
||||
} else if (version.startsWith("Databricks")) {
|
||||
return "DATABRICKS";
|
||||
} else if (version.contains("HDP")) {
|
||||
return "HORTONWORKS";
|
||||
} else if (version.startsWith("MICROSOFT_HD_INSIGHT")) {
|
||||
return "MICROSOFT_HD_INSIGHT";
|
||||
} else if (version.startsWith("SPARK")) {
|
||||
return "SPARK";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setDistribution(NodeType node, String dbVersionName) {
|
||||
if (node == null || dbVersionName == null) {
|
||||
return;
|
||||
}
|
||||
EList<ElementParameterType> elementParameters = node.getElementParameter();
|
||||
String distribution = null;
|
||||
String dbVersion = null;
|
||||
// Iterate over the item elementParameters in order to find the "DISTRIBUTION" and "SPARK_VERSION"
|
||||
// parameters values.
|
||||
for (int i = 0; i < elementParameters.size(); i++) {
|
||||
ElementParameterType param = elementParameters.get(i);
|
||||
if (dbVersionName.equals(param.getName())) {
|
||||
dbVersion = param.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
ElementParameterType property = TalendFileFactory.eINSTANCE.createElementParameterType();
|
||||
distribution = BigDataBasicUtil.getDistributionByVersion(dbVersion);
|
||||
if (distribution != null) {
|
||||
property.setName("DISTRIBUTION"); //$NON-NLS-1$
|
||||
property.setField("CLOSED_LIST"); //$NON-NLS-1$
|
||||
property.setValue(distribution);
|
||||
elementParameters.add(property);
|
||||
} else {
|
||||
ExceptionHandler.log("no matched distribution for version " + dbVersion);//$NON-NLS-1$
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.log(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,10 @@ public class HadoopConstants {
|
||||
public static final String SPARK_MODE_YARN_CLUSTER = "YARN_CLUSTER";
|
||||
|
||||
public static final String SPARK_MODE_DATAPROC = "DATAPROC";
|
||||
|
||||
public static final String SPARK_MODE_SYNAPSE = "SYNAPSE";
|
||||
|
||||
public static final String SPARK_MODE_HDI = "HDI";
|
||||
|
||||
public static final String FRAMEWORK = "FRAMEWORK";
|
||||
|
||||
|
||||
@@ -142,6 +142,8 @@ public enum EHadoopProperties {
|
||||
|
||||
SPARK_EXECUTOR_MEMORY,
|
||||
|
||||
SPARK_EXECUTOR_CORES,
|
||||
|
||||
DATABRICKS_ENDPOINT,
|
||||
|
||||
DATABRICKS_CLOUD_PROVIDER,
|
||||
|
||||
@@ -984,6 +984,14 @@ public class ContextUtils {
|
||||
|
||||
}
|
||||
|
||||
public boolean remove(Item item, String param) {
|
||||
Set<String> params = map.get(item);
|
||||
if (params != null && params.contains(param)) {
|
||||
return params.remove(param);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return map.isEmpty();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.utils.ContextParameterUtils;
|
||||
import org.talend.cwm.helper.ResourceHelper;
|
||||
import org.talend.cwm.helper.StudioEncryptionHelper;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
|
||||
@@ -335,6 +336,8 @@ public class JobContextManager implements IContextManager {
|
||||
} else {
|
||||
contextParam.setType(MetadataTalendType.getDefaultTalendType());
|
||||
}
|
||||
//To avoid encrypt the same value}
|
||||
contextParam.setOriginEncryptedValue(contextParamType.getValue());
|
||||
contextParam.setValue(contextParamType.getRawValue());
|
||||
|
||||
contextParam.setPromptNeeded(contextParamType.isPromptNeeded());
|
||||
@@ -560,7 +563,10 @@ public class JobContextManager implements IContextManager {
|
||||
contextParamType.setName(contextParam.getName());
|
||||
contextParamType.setPrompt(contextParam.getPrompt());
|
||||
contextParamType.setType(contextParam.getType());
|
||||
//To avoid encrypt the same value
|
||||
contextParamType.setValue(contextParam.getOriginEncryptedValue());
|
||||
contextParamType.setRawValue(contextParam.getValue());
|
||||
contextParam.setOriginEncryptedValue(contextParamType.getValue()); // For origin encrypted value is null or encryption key upgrade
|
||||
contextParamType.setPromptNeeded(contextParam.isPromptNeeded());
|
||||
contextParamType.setComment(contextParam.getComment());
|
||||
if (!contextParam.isBuiltIn()) {
|
||||
|
||||
@@ -46,6 +46,9 @@ public class JobContextParameter implements IContextParameter, Cloneable {
|
||||
String[] valueList;
|
||||
|
||||
String internalId;
|
||||
|
||||
/*This value may dirty, only use to cache encrypted value*/
|
||||
String originEncryptedValue;
|
||||
|
||||
/**
|
||||
* change to save id always for bug 13184.
|
||||
@@ -301,6 +304,15 @@ public class JobContextParameter implements IContextParameter, Cloneable {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getOriginEncryptedValue() {
|
||||
return originEncryptedValue;
|
||||
}
|
||||
|
||||
|
||||
public void setOriginEncryptedValue(String originEncryptedValue) {
|
||||
this.originEncryptedValue = originEncryptedValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -1091,6 +1091,10 @@ public class RepositoryToComponentProperty {
|
||||
if (dbVersionString != null) {
|
||||
return dbVersionString.toUpperCase();
|
||||
}
|
||||
} else if (EDatabaseConnTemplate.AMAZON_AURORA.getDBDisplayName().equals(databaseType)) {
|
||||
if (dbVersionString != null) {
|
||||
return dbVersionString.toUpperCase();
|
||||
}
|
||||
} else if (EDatabaseTypeName.HIVE.getDisplayName().equals(databaseType)) {
|
||||
return connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_VERSION);
|
||||
} else if (EDatabaseTypeName.HBASE.getDisplayName().equals(databaseType)) {
|
||||
|
||||
@@ -75,4 +75,9 @@ public interface IContextParameter {
|
||||
public String getInternalId();
|
||||
|
||||
public void setInternalId(String internalId);
|
||||
|
||||
/*This value may dirty, only use to cache encrypted value*/
|
||||
public String getOriginEncryptedValue();
|
||||
|
||||
public void setOriginEncryptedValue(String originEncryptedValue);
|
||||
}
|
||||
|
||||
@@ -234,4 +234,9 @@ public interface IElementParameter {
|
||||
public void setSerialized(boolean isSerialized);
|
||||
|
||||
public boolean isSelectedFromItemValue();
|
||||
|
||||
/*This value may dirty, only use to cache encrypted value*/
|
||||
public String getOrignEncryptedValue();
|
||||
|
||||
public void setOrignEncryptedValue(String value);
|
||||
}
|
||||
|
||||
@@ -71,6 +71,9 @@ public interface IProcess2 extends IRepositoryObject, IProcess {
|
||||
@Override
|
||||
void setActivate(boolean b);
|
||||
|
||||
public boolean isRefactoringToJoblet();
|
||||
|
||||
public void refactoringToJoblet(boolean isRefactoring);
|
||||
/**
|
||||
* DOC qzhang Comment method "checkStartNodes".
|
||||
*/
|
||||
|
||||
@@ -368,6 +368,9 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
|
||||
"repository.metadataCalculationView", "METADATA_CON_CALCULATION_VIEW", 106, true, true, new String[] { PROD_DI },
|
||||
new String[] {}, false);
|
||||
|
||||
public final static ERepositoryObjectType METADATA_SAP_CDS_VIEW = new ERepositoryObjectType("repository.SAPTable", //$NON-NLS-1$
|
||||
"METADATA_SAP_CDS_VIEW", 107, true, true, new String[] { PROD_DI }, new String[] {}, false);
|
||||
|
||||
private String label;
|
||||
|
||||
private String alias;
|
||||
|
||||
@@ -79,4 +79,8 @@ public final class TalendPropertiesUtil {
|
||||
public static String getProductApp() {
|
||||
return System.getProperty(PROD_APP);
|
||||
}
|
||||
|
||||
public static boolean isEnabledUseShortJobletName() {
|
||||
return isEnabled("talend.job.build.useShortJobletName"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,10 @@ public interface IStudioLiteP2Service extends IService {
|
||||
|
||||
void setupTmcUpdate(IProgressMonitor monitor, IStudioUpdateConfig updateConfig) throws Exception;
|
||||
|
||||
void handleTmcUpdateObserve(boolean trunOn);
|
||||
|
||||
boolean isUpdateManagedByTmc(IProgressMonitor monitor);
|
||||
|
||||
boolean removeM2() throws Exception;
|
||||
|
||||
void saveRemoveM2(boolean remove) throws Exception;
|
||||
@@ -279,6 +283,10 @@ public interface IStudioLiteP2Service extends IService {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
throw new Exception("status code: " + responseCode);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -322,7 +330,7 @@ public interface IStudioLiteP2Service extends IService {
|
||||
String nodeName = IRepository.PREFERENCE_NODE + '/' + nodeKey;
|
||||
|
||||
if (securePreferences.nodeExists(nodeName)) {
|
||||
securePreferences.remove(nodeName);
|
||||
securePreferences.node(nodeName).removeNode();
|
||||
securePreferences.flush();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class ContextTreeTable {
|
||||
|
||||
private NatTable natTable;
|
||||
|
||||
// for bug TDI-32821, use LinkedList to keep the original order of context parameter list.
|
||||
// for bug TDI-32821锛<EFBFBD> use LinkedList to keep the original order of context parameter list.
|
||||
private List<ContextTreeNode> treeNodes = new LinkedList<ContextTreeNode>();
|
||||
|
||||
private static Map<String, Boolean> expandMap = new HashMap<>();
|
||||
|
||||
@@ -28,10 +28,10 @@ public class ContextTableConstants {
|
||||
public static final String COLUMN_PROMPT_PROPERTY = "Prompt label"; //$NON-NLS-1$
|
||||
|
||||
public static final String COLUMN_CONTEXT_VALUE = "Value"; //$NON-NLS-1$
|
||||
|
||||
public static final String LABEL_VALUE_NOT_MATCH_TYPE = "LABEL_VALUE_NOT_MATCH_TYPE";
|
||||
|
||||
|
||||
public static final String LABEL_CHANGED_FORCEGROUND = "LABEL_CHANGED_FORCEGROUND";
|
||||
|
||||
|
||||
public static final String LABEL_VALUE_NOT_MATCH_TYPE = "LABEL_VALUE_NOT_MATCH_TYPE";
|
||||
|
||||
public static final int DEFAULT_COLUMN_COUNT = 8;
|
||||
}
|
||||
|
||||
@@ -73,16 +73,16 @@ public class ContextNatTableStyleConfiguration extends AbstractRegistryConfigura
|
||||
cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, vAlign);
|
||||
cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, borderStyle);
|
||||
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle);
|
||||
|
||||
|
||||
Style cellStyleValueError = new Style();
|
||||
cellStyleValueError.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, ColorConstants.ERROR_FONT_COLOR);
|
||||
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyleValueError, DisplayMode.NORMAL, ContextTableConstants.LABEL_VALUE_NOT_MATCH_TYPE);
|
||||
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyleValueError, DisplayMode.SELECT, ContextTableConstants.LABEL_VALUE_NOT_MATCH_TYPE);
|
||||
|
||||
Style cellStyleChangedForceGround = new Style();
|
||||
cellStyleChangedForceGround.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, GUIHelper.COLOR_WIDGET_DARK_SHADOW);
|
||||
cellStyleChangedForceGround.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, ColorConstants.getTableReadOnlyForegroundColor());
|
||||
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyleChangedForceGround, DisplayMode.NORMAL, ContextTableConstants.LABEL_CHANGED_FORCEGROUND);
|
||||
|
||||
|
||||
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDisplayConverter());
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.ui.context.ContextTreeTable.ContextTreeNode;
|
||||
import org.talend.core.ui.context.model.ContextTabChildModel;
|
||||
import org.talend.core.ui.context.model.table.ContextTableConstants;
|
||||
import org.talend.core.ui.context.model.table.ContextTableTabParentModel;
|
||||
import org.talend.core.ui.context.model.table.ContextTableTabParentModel;
|
||||
import org.talend.core.ui.utils.ContextTypeValidator;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ContextValueLabelAccumulator extends ColumnOverrideLabelAccumulator
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!isAddedValueNotMatchStyle) {
|
||||
if (rowNode.getTreeData() instanceof ContextTableTabParentModel) {
|
||||
ContextTableTabParentModel rowModel = (ContextTableTabParentModel) rowNode.getTreeData();
|
||||
|
||||
@@ -134,7 +134,7 @@ public final class TokenInforUtil {
|
||||
targetArray = new JSONArray();
|
||||
Map<String,List<JSONObject>> objectMap = new HashMap<String,List<JSONObject>>();
|
||||
for (Object obj : data) {
|
||||
if((obj instanceof JSONObject) && ((JSONObject)obj).get("component_name")!=null){//$NON-NLS-1$
|
||||
if((obj instanceof JSONObject) && ((JSONObject)obj).has("component_name") && ((JSONObject)obj).get("component_name")!=null){//$NON-NLS-1$
|
||||
List<JSONObject> dataList = new ArrayList<JSONObject>();
|
||||
String componentName = (String) ((JSONObject)obj).get("component_name");//$NON-NLS-1$
|
||||
if(objectMap.containsKey(componentName)){
|
||||
|
||||
@@ -317,3 +317,4 @@ ActionBarBuildHelper.SaveAll_toolTip=Save All
|
||||
ContextOrderProperty.BuiltInComment=Built-in context variables
|
||||
ContextOrderProperty.RepositoryComment=Context variables from repository context:
|
||||
BaseComponentInstallerTask.installComponent=Installing component {0}
|
||||
ApplicationWorkbenchWindowAdvisor.repositoryConnection=Connection
|
||||
|
||||
@@ -47,6 +47,8 @@ public class ObjectElementParameter implements IElementParameter {
|
||||
|
||||
private boolean enable = true;
|
||||
|
||||
private String originEncryptedValue;
|
||||
|
||||
/**
|
||||
* Constructs a new TextElementParameter.
|
||||
*/
|
||||
@@ -1052,4 +1054,15 @@ public class ObjectElementParameter implements IElementParameter {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrignEncryptedValue() {
|
||||
return originEncryptedValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrignEncryptedValue(String value) {
|
||||
this.originEncryptedValue = value;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2023 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.model.utils;
|
||||
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.i18n.Messages;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.service.IRemoteService;
|
||||
import org.talend.core.service.IStudioLiteP2Service;
|
||||
import org.talend.core.ui.IInstalledPatchService;
|
||||
import org.talend.core.ui.branding.IBrandingService;
|
||||
import org.talend.repository.ui.login.connections.ConnectionUserPerReader;
|
||||
|
||||
/**
|
||||
* DOC jding class global comment. Detailled comment
|
||||
*/
|
||||
public class TalendWorkbenchUtil {
|
||||
|
||||
public static final String MANAGED_BY_ADMIN = " Managed by administrator"; //$NON-NLS-1$
|
||||
|
||||
public static String getWorkbenchWindowTitle() {
|
||||
String title = "";
|
||||
RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext()
|
||||
.getProperty(Context.REPOSITORY_CONTEXT_KEY);
|
||||
Project project = repositoryContext.getProject();
|
||||
String appName = IBrandingService.get().getFullProductName();
|
||||
// TDI-18644
|
||||
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
boolean localProvider = false;
|
||||
try {
|
||||
localProvider = factory.isLocalConnectionProvider();
|
||||
} catch (PersistenceException e) {
|
||||
localProvider = true;
|
||||
}
|
||||
|
||||
String buildIdField = " (" + VersionUtils.getVersion() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IInstalledPatchService.class)) {
|
||||
IInstalledPatchService pachService = (IInstalledPatchService) GlobalServiceRegister.getDefault()
|
||||
.getService(IInstalledPatchService.class);
|
||||
if (pachService != null) {
|
||||
String patchVersion = pachService.getLatestInstalledVersion(true);
|
||||
if (patchVersion != null) {
|
||||
buildIdField = " (" + patchVersion + ")"; //$NON-NLS-1$ //$NON-NLS-2$ ;
|
||||
if (IRemoteService.get() != null && IRemoteService.get().isCloudConnection()) {
|
||||
IStudioLiteP2Service liteP2Service = IStudioLiteP2Service.get();
|
||||
if (liteP2Service != null && liteP2Service.isUpdateManagedByTmc(new NullProgressMonitor())) {
|
||||
buildIdField += MANAGED_BY_ADMIN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TalendPropertiesUtil.isHideBuildNumber()) {
|
||||
buildIdField = ""; //$NON-NLS-1$
|
||||
}
|
||||
if (localProvider) {
|
||||
title = appName + buildIdField + " | " + project.getLabel() + " (" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ Messages.getString("ApplicationWorkbenchWindowAdvisor.repositoryConnection") + ": " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ ConnectionUserPerReader.getInstance().readLastConncetion() + ")"; //$NON-NLS-1$
|
||||
} else {
|
||||
title = appName + buildIdField + " | " + repositoryContext.getUser() + " | " + project.getLabel() + " (" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ Messages.getString("ApplicationWorkbenchWindowAdvisor.repositoryConnection") + ": " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ ConnectionUserPerReader.getInstance().readLastConncetion() + ")"; //$NON-NLS-1$
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -63,6 +63,12 @@ public interface IGITProviderService extends IService {
|
||||
*/
|
||||
boolean isStandardMode();
|
||||
|
||||
/**
|
||||
* Whether git storage mode is set in preference or not
|
||||
* @return
|
||||
*/
|
||||
boolean isGitModeInPreference();
|
||||
|
||||
/**
|
||||
* Set git mode
|
||||
* @param standardMode
|
||||
@@ -89,4 +95,6 @@ public interface IGITProviderService extends IService {
|
||||
}
|
||||
return register.getService(IGITProviderService.class);
|
||||
}
|
||||
|
||||
public void clearOldStorage(IProgressMonitor monitor, Project project) throws PersistenceException;
|
||||
}
|
||||
|
||||
@@ -861,7 +861,7 @@ public class ProcessorUtilities {
|
||||
for (IContext context : list) {
|
||||
if (context.getName().equals(currentContext.getName())) {
|
||||
// override parameter value before generate current context
|
||||
IContext checkedContext = checkNeedOverrideContextParameterValue(context, jobInfo);
|
||||
IContext checkedContext = checkNeedOverrideContextParameterValue(currentContext, jobInfo);
|
||||
checkedContext = checkCleanSecureContextParameterValue(checkedContext, jobInfo);
|
||||
processor.setContext(checkedContext); // generate current context.
|
||||
} else {
|
||||
@@ -1076,6 +1076,21 @@ public class ProcessorUtilities {
|
||||
}
|
||||
progressMonitor.subTask(Messages.getString("ProcessorUtilities.loadingJob") + currentJobName); //$NON-NLS-1$
|
||||
|
||||
//APPINT-35554 correct build type for child job of Route
|
||||
JobInfo parentJobInfo = jobInfo.getFatherJobInfo();
|
||||
if (selectedProcessItem != null && parentJobInfo != null
|
||||
&& parentJobInfo.getProcessor() != null && parentJobInfo.getProcessor().getProperty() != null ) {
|
||||
Property childProperty = selectedProcessItem.getProperty();
|
||||
String childBuildType = (String)childProperty.getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
|
||||
if (childBuildType == null) {
|
||||
Property parentProperty = parentJobInfo.getProcessor().getProperty();
|
||||
String parentBuildType = (String)parentProperty.getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
|
||||
if ("ROUTE".equalsIgnoreCase(parentBuildType)) {
|
||||
childProperty.getAdditionalProperties().put(TalendProcessArgumentConstant.ARG_BUILD_TYPE, "OSGI");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (jobInfo.getProcess() == null) {
|
||||
if (selectedProcessItem != null) {
|
||||
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
|
||||
|
||||
@@ -22,7 +22,7 @@ _UI_Dependency_type=\u4F9D\u5B58\u9805\u76EE
|
||||
_UI_Expression_type=\u5F0F
|
||||
_UI_BooleanExpression_type=\u30D6\u30FC\u30EB\u5024\u306E\u5F0F
|
||||
_UI_ProcedureExpression_type=\u30D7\u30ED\u30B7\u30FC\u30B8\u30E3\u30FC\u30A8\u30AF\u30B9\u30D7\u30EC\u30C3\u30B7\u30E7\u30F3
|
||||
_UI_Multiplicity_type=\u591A\u69D8\u6027
|
||||
_UI_Multiplicity_type=\u591A\u91CD\u5EA6
|
||||
_UI_MultiplicityRange_type=\u591A\u69D8\u6027\u30EC\u30F3\u30B8
|
||||
_UI_Stereotype_type=\u30B9\u30C6\u30EC\u30AA\u30BF\u30A4\u30D7
|
||||
_UI_TaggedValue_type=\u30BF\u30B0\u4ED8\u3051\u3055\u308C\u305F\u5024
|
||||
@@ -151,7 +151,7 @@ _UI_ApplicationInputSpecification_type=\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E
|
||||
_UI_AttributeUsageRelation_type=\u5C5E\u6027\u7528\u6CD5\u95A2\u4FC2
|
||||
_UI_Category_type=\u30AB\u30C6\u30B4\u30EA\u30FC
|
||||
_UI_CategoryHierarchy_type=\u30AB\u30C6\u30B4\u30EA\u30FC\u968E\u5C64
|
||||
_UI_CostMatrix_type=\u30B3\u30B9\u30C8\u30DE\u30C8\u30EA\u30C3\u30AF\u30B9
|
||||
_UI_CostMatrix_type=\u30B3\u30B9\u30C8\u30DE\u30C8\u30EA\u30AF\u30B9
|
||||
_UI_MiningAttribute_type=\u30DE\u30A4\u30CB\u30F3\u30B0\u5C5E\u6027
|
||||
_UI_MiningDataSpecification_type=\u30DE\u30A4\u30CB\u30F3\u30B0\u30C7\u30FC\u30BF\u4ED5\u69D8
|
||||
_UI_MiningModel_type=\u30DE\u30A4\u30CB\u30F3\u30B0\u30E2\u30C7\u30EB
|
||||
@@ -367,7 +367,7 @@ _UI_Feature_featureNode_feature=\u6A5F\u80FD\u30CE\u30FC\u30C9
|
||||
_UI_Feature_featureMap_feature=\u6A5F\u80FD\u30DE\u30C3\u30D7
|
||||
_UI_Feature_cfMap_feature=Cf\u30DE\u30C3\u30D7
|
||||
_UI_StructuralFeature_changeability_feature=\u53EF\u5909\u6027
|
||||
_UI_StructuralFeature_multiplicity_feature=\u591A\u69D8\u6027
|
||||
_UI_StructuralFeature_multiplicity_feature=\u591A\u91CD\u5EA6
|
||||
_UI_StructuralFeature_ordering_feature=\u9806\u5E8F\u4ED8\u3051
|
||||
_UI_StructuralFeature_targetScope_feature=\u30BF\u30FC\u30B2\u30C3\u30C8\u30B9\u30B3\u30FC\u30D7
|
||||
_UI_StructuralFeature_type_feature=\u30BF\u30A4\u30D7
|
||||
@@ -390,7 +390,7 @@ _UI_Expression_language_feature=\u8A00\u8A9E
|
||||
_UI_Multiplicity_range_feature=\u7BC4\u56F2
|
||||
_UI_MultiplicityRange_lower_feature=\u4E0B\u65B9
|
||||
_UI_MultiplicityRange_upper_feature=\u4E0A\u65B9
|
||||
_UI_MultiplicityRange_multiplicity_feature=\u591A\u69D8\u6027
|
||||
_UI_MultiplicityRange_multiplicity_feature=\u591A\u91CD\u5EA6
|
||||
_UI_Stereotype_baseClass_feature=\u30D9\u30FC\u30B9\u30AF\u30E9\u30B9
|
||||
_UI_Stereotype_stereotypeConstraint_feature=\u30B9\u30C6\u30EC\u30AA\u30BF\u30A4\u30D7\u5236\u7D04
|
||||
_UI_Stereotype_extendedElement_feature=\u62E1\u5F35\u3055\u308C\u305F\u30A8\u30EC\u30E1\u30F3\u30C8
|
||||
@@ -418,7 +418,7 @@ _UI_Parameter_behavioralFeature_feature=\u52D5\u4F5C\u6A5F\u80FD
|
||||
_UI_Parameter_event_feature=\u30A4\u30D9\u30F3\u30C8
|
||||
_UI_Parameter_type_feature=\u30BF\u30A4\u30D7
|
||||
_UI_AssociationEnd_aggregation_feature=\u96C6\u7D04
|
||||
_UI_AssociationEnd_isNavigable_feature=Navigable\u3067\u3042\u308B
|
||||
_UI_AssociationEnd_isNavigable_feature=\u8A98\u5C0E\u53EF\u80FD\u3067\u3042\u308B
|
||||
_UI_Generalization_child_feature=\u5B50
|
||||
_UI_Generalization_parent_feature=\u89AA
|
||||
_UI_Instance_valueSlot_feature=\u5024\u30BB\u30C3\u30C8
|
||||
@@ -552,7 +552,7 @@ _UI_Column_isNullable_feature=NULL\u53EF\u80FD
|
||||
_UI_Column_length_feature=\u9577\u3055
|
||||
_UI_Column_collationName_feature=\u7167\u5408\u540D
|
||||
_UI_Column_characterSetName_feature=\u6587\u5B57\u30BB\u30C3\u30C8\u540D
|
||||
_UI_Column_referencedTableType_feature=\u53C2\u7167\u3055\u308C\u308B\u30C6\u30FC\u30D6\u30EB\u30BF\u30A4\u30D7
|
||||
_UI_Column_referencedTableType_feature=\u53C2\u7167\u30C6\u30FC\u30D6\u30EB\u30BF\u30A4\u30D7
|
||||
_UI_Column_optionScopeColumnSet_feature=\u30AA\u30D7\u30B7\u30E7\u30F3\u30B9\u30B3\u30FC\u30D7\u30AB\u30E9\u30E0\u30BB\u30C3\u30C8
|
||||
_UI_Procedure_type_feature=\u30BF\u30A4\u30D7
|
||||
_UI_Trigger_eventManipulation_feature=\u30A4\u30D9\u30F3\u30C8\u64CD\u4F5C
|
||||
@@ -743,7 +743,7 @@ _UI_ClusteringSettings_clusterIdAttributeName_feature=\u30AF\u30E9\u30B9\u30BF\u
|
||||
_UI_SupervisedMiningSettings_confidenceAttributeName_feature=\u4FE1\u7528\u5C5E\u6027\u540D
|
||||
_UI_SupervisedMiningSettings_predictedAttributeName_feature=\u4E88\u6E2C\u3055\u308C\u308B\u5C5E\u6027\u540D
|
||||
_UI_SupervisedMiningSettings_costFunction_feature=\u30B3\u30B9\u30C8\u95A2\u6570
|
||||
_UI_ClassificationSettings_costMatrix_feature=\u30B3\u30B9\u30C8\u30DE\u30C8\u30EA\u30C3\u30AF\u30B9
|
||||
_UI_ClassificationSettings_costMatrix_feature=\u30B3\u30B9\u30C8\u30DE\u30C8\u30EA\u30AF\u30B9
|
||||
_UI_AssociationRulesSettings_minimumSupport_feature=\u6700\u5C0F\u30B5\u30DD\u30FC\u30C8
|
||||
_UI_AssociationRulesSettings_minimumConfidence_feature=\u6700\u5C0F\u306E\u4FE1\u7528
|
||||
_UI_AssociationRulesSettings_itemId_feature=\u30A2\u30A4\u30C6\u30E0ID
|
||||
|
||||
@@ -184,10 +184,10 @@ _UI_RecordEditor_label = \u30EC\u30B3\u30FC\u30C9\u30E2\u30C7\u30EB\u30A8\u30C7\
|
||||
_UI_RecordEditorFilenameDefaultBase = My
|
||||
_UI_RecordEditorFilenameExtension = \u30EC\u30B3\u30FC\u30C9
|
||||
|
||||
_UI_MultidimensionalModelWizard_label = \u591A\u6B21\u5143\u7684\u30E2\u30C7\u30EB
|
||||
_UI_MultidimensionalModelWizard_description = \u65B0\u898F\u306E\u591A\u6B21\u5143\u7684\u30E2\u30C7\u30EB\u3092\u4F5C\u6210
|
||||
_UI_MultidimensionalModelWizard_label = \u591A\u6B21\u5143\u30E2\u30C7\u30EB
|
||||
_UI_MultidimensionalModelWizard_description = \u65B0\u898F\u306E\u591A\u6B21\u5143\u30E2\u30C7\u30EB\u3092\u4F5C\u6210
|
||||
|
||||
_UI_MultidimensionalEditor_label = \u591A\u6B21\u5143\u7684\u30E2\u30C7\u30EB\u30A8\u30C7\u30A3\u30BF
|
||||
_UI_MultidimensionalEditor_label = \u591A\u6B21\u5143\u30E2\u30C7\u30EB\u30A8\u30C7\u30A3\u30BF\u30FC
|
||||
|
||||
_UI_MultidimensionalEditorFilenameDefaultBase = My
|
||||
_UI_MultidimensionalEditorFilenameExtension = \u591A\u6B21\u5143\u7684
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
<jcache.version>1.0.5</jcache.version>
|
||||
<jcache_spec.version>1.0-alpha-1</jcache_spec.version>
|
||||
<johnzon.version>1.2.19</johnzon.version>
|
||||
<meecrowave.version>1.2.14</meecrowave.version>
|
||||
<meecrowave.version>1.2.15</meecrowave.version>
|
||||
<microprofile.version>1.2.1</microprofile.version>
|
||||
<owb.version>2.0.27</owb.version>
|
||||
<slf4j.version>1.7.34</slf4j.version>
|
||||
<tomcat.version>9.0.69</tomcat.version>
|
||||
<tomcat.version>9.0.73</tomcat.version>
|
||||
<xbean.version>4.20</xbean.version>
|
||||
<reload4j.version>1.2.22</reload4j.version>
|
||||
<log4j2.version>2.18.0</log4j2.version>
|
||||
<log4j2.version>2.20.0</log4j2.version>
|
||||
<tycho.buildtimestamp.format>${timestamp}</tycho.buildtimestamp.format>
|
||||
</properties>
|
||||
<repositories>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<talend_releases>https://artifacts-oss.talend.com/nexus/content/repositories/TalendOpenSourceRelease/</talend_releases>
|
||||
<talend_snapshots_ee>https://artifacts-zl.talend.com/nexus/content/repositories/snapshots/</talend_snapshots_ee>
|
||||
<talend_releases_ee>https://artifacts-zl.talend.com/nexus/content/repositories/releases/</talend_releases_ee>
|
||||
<tycho.buildtimestamp.format>${timestamp}</tycho.buildtimestamp.format>
|
||||
<tycho.buildtimestamp.format>${timestamp}</tycho.buildtimestamp.format>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
@@ -72,15 +72,15 @@
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20140107</version>
|
||||
<version>20230227</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-cbor</artifactId>
|
||||
<version>${m2.fasterxml.jackson.version}</version>
|
||||
</dependency>
|
||||
<!-- It fixes provided dependency scope to compile, because maven-dependency-plugin is setup to include
|
||||
only compile and runtime scopes, but provided is also required. It's not possible to setup plugin to
|
||||
<!-- It fixes provided dependency scope to compile, because maven-dependency-plugin is setup to include
|
||||
only compile and runtime scopes, but provided is also required. It's not possible to setup plugin to
|
||||
include all: compile, runtime and provided dependencies -->
|
||||
<dependency>
|
||||
<groupId>biz.aQute.bnd</groupId>
|
||||
@@ -99,7 +99,7 @@
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<!-- Dependencies in provided scope should be explicitly added as dependency in this module,
|
||||
<!-- Dependencies in provided scope should be explicitly added as dependency in this module,
|
||||
because provided scope is not transitive -->
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
|
||||
@@ -52,8 +52,17 @@
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
@@ -67,7 +76,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-framework-bom</artifactId>
|
||||
<version>5.2.7.RELEASE</version>
|
||||
<version>5.2.9.RELEASE</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -59,8 +59,17 @@
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
@@ -99,7 +108,7 @@
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>1.4.16</version>
|
||||
<version>1.4.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>3.8.6</version>
|
||||
<version>3.8.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>3.8.6</version>
|
||||
<version>3.8.8</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-io</groupId>
|
||||
@@ -123,7 +123,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-compat</artifactId>
|
||||
<version>3.8.6</version>
|
||||
<version>3.8.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20140107</version>
|
||||
<version>20230227</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.2.6</version>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<tcomp.version>1.54.0</tcomp.version>
|
||||
<tcomp.version>1.57.1</tcomp.version>
|
||||
<slf4j.version>1.7.34</slf4j.version>
|
||||
<reload4j.version>1.2.22</reload4j.version>
|
||||
</properties>
|
||||
|
||||
@@ -37,3 +37,4 @@ Export-Package: org.talend.designer.maven,
|
||||
org.talend.designer.maven.tools.extension,
|
||||
org.talend.designer.maven.utils
|
||||
Import-Package: org.slf4j
|
||||
|
||||
|
||||
@@ -26,5 +26,4 @@
|
||||
serviceId="IDesignerMavenService">
|
||||
</Service>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-compat</artifactId>
|
||||
<version>3.8.6</version>
|
||||
<version>3.8.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
@@ -69,7 +69,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>3.8.6</version>
|
||||
<version>3.8.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
@@ -101,7 +101,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>3.8.6</version>
|
||||
<version>3.8.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
@@ -148,7 +148,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>3.8.6</version>
|
||||
<version>3.8.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
@@ -200,12 +200,12 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-compat</artifactId>
|
||||
<version>3.8.6</version>
|
||||
<version>3.8.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>3.8.6</version>
|
||||
<version>3.8.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
|
||||
@@ -231,7 +231,7 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
Dependency mavenCoreDep = new Dependency();
|
||||
mavenCoreDep.setGroupId("org.apache.maven");
|
||||
mavenCoreDep.setArtifactId("maven-core");
|
||||
mavenCoreDep.setVersion("3.8.6");
|
||||
mavenCoreDep.setVersion("3.8.8");
|
||||
|
||||
shade.getDependencies().add(guavaDep);
|
||||
shade.getDependencies().add(codecDep);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,223 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ------------------------------
|
||||
* CombinedCategoryPlotDemo1.java
|
||||
* ------------------------------
|
||||
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): ;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 05-May-2008 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.experimental.chart.demo;
|
||||
|
||||
import java.awt.Font;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.jfree.chart.ChartPanel;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
import org.jfree.chart.axis.CategoryAxis;
|
||||
import org.jfree.chart.axis.NumberAxis;
|
||||
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.renderer.category.BarRenderer;
|
||||
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
|
||||
import org.jfree.data.category.CategoryDataset;
|
||||
import org.jfree.data.category.DefaultCategoryDataset;
|
||||
import org.jfree.experimental.chart.plot.CombinedCategoryPlot;
|
||||
import org.jfree.ui.ApplicationFrame;
|
||||
import org.jfree.ui.RefineryUtilities;
|
||||
|
||||
/**
|
||||
* A demo for the {@link CombinedCategoryPlot} class.
|
||||
*/
|
||||
public class CombinedCategoryPlotDemo1 extends ApplicationFrame {
|
||||
|
||||
/**
|
||||
* Creates a new demo instance.
|
||||
*
|
||||
* @param title the frame title.
|
||||
*/
|
||||
public CombinedCategoryPlotDemo1(String title) {
|
||||
super(title);
|
||||
JPanel chartPanel = createDemoPanel();
|
||||
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
|
||||
setContentPane(chartPanel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a dataset.
|
||||
*
|
||||
* @return A dataset.
|
||||
*/
|
||||
public static CategoryDataset createDataset1() {
|
||||
DefaultCategoryDataset result = new DefaultCategoryDataset();
|
||||
String series1 = "First";
|
||||
String series2 = "Second";
|
||||
String type1 = "Type 1";
|
||||
String type2 = "Type 2";
|
||||
String type3 = "Type 3";
|
||||
String type4 = "Type 4";
|
||||
String type5 = "Type 5";
|
||||
String type6 = "Type 6";
|
||||
String type7 = "Type 7";
|
||||
String type8 = "Type 8";
|
||||
|
||||
result.addValue(1.0, series1, type1);
|
||||
result.addValue(4.0, series1, type2);
|
||||
result.addValue(3.0, series1, type3);
|
||||
result.addValue(5.0, series1, type4);
|
||||
result.addValue(5.0, series1, type5);
|
||||
result.addValue(7.0, series1, type6);
|
||||
result.addValue(7.0, series1, type7);
|
||||
result.addValue(8.0, series1, type8);
|
||||
|
||||
result.addValue(5.0, series2, type1);
|
||||
result.addValue(7.0, series2, type2);
|
||||
result.addValue(6.0, series2, type3);
|
||||
result.addValue(8.0, series2, type4);
|
||||
result.addValue(4.0, series2, type5);
|
||||
result.addValue(4.0, series2, type6);
|
||||
result.addValue(2.0, series2, type7);
|
||||
result.addValue(1.0, series2, type8);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a dataset.
|
||||
*
|
||||
* @return A dataset.
|
||||
*/
|
||||
public static CategoryDataset createDataset2() {
|
||||
|
||||
DefaultCategoryDataset result = new DefaultCategoryDataset();
|
||||
|
||||
String series1 = "Third";
|
||||
String series2 = "Fourth";
|
||||
|
||||
String type1 = "Type 1";
|
||||
String type2 = "Type 2";
|
||||
String type3 = "Type 3";
|
||||
String type4 = "Type 4";
|
||||
String type5 = "Type 5";
|
||||
String type6 = "Type 6";
|
||||
String type7 = "Type 7";
|
||||
String type8 = "Type 8";
|
||||
|
||||
result.addValue(11.0, series1, type1);
|
||||
result.addValue(14.0, series1, type2);
|
||||
result.addValue(13.0, series1, type3);
|
||||
result.addValue(15.0, series1, type4);
|
||||
result.addValue(15.0, series1, type5);
|
||||
result.addValue(17.0, series1, type6);
|
||||
result.addValue(17.0, series1, type7);
|
||||
result.addValue(18.0, series1, type8);
|
||||
|
||||
result.addValue(15.0, series2, type1);
|
||||
result.addValue(17.0, series2, type2);
|
||||
result.addValue(16.0, series2, type3);
|
||||
result.addValue(18.0, series2, type4);
|
||||
result.addValue(14.0, series2, type5);
|
||||
result.addValue(14.0, series2, type6);
|
||||
result.addValue(12.0, series2, type7);
|
||||
result.addValue(11.0, series2, type8);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a chart.
|
||||
*
|
||||
* @return A chart.
|
||||
*/
|
||||
private static JFreeChart createChart() {
|
||||
|
||||
CategoryDataset dataset1 = createDataset1();
|
||||
NumberAxis rangeAxis1 = new NumberAxis("Value");
|
||||
rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
|
||||
LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
|
||||
renderer1.setBaseToolTipGenerator(
|
||||
new StandardCategoryToolTipGenerator());
|
||||
CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1,
|
||||
renderer1);
|
||||
subplot1.setDomainGridlinesVisible(true);
|
||||
|
||||
CategoryDataset dataset2 = createDataset2();
|
||||
NumberAxis rangeAxis2 = new NumberAxis("Value");
|
||||
rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
|
||||
BarRenderer renderer2 = new BarRenderer();
|
||||
renderer2.setBaseToolTipGenerator(
|
||||
new StandardCategoryToolTipGenerator());
|
||||
CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2,
|
||||
renderer2);
|
||||
subplot2.setDomainGridlinesVisible(true);
|
||||
|
||||
CategoryAxis domainAxis = new CategoryAxis("Category");
|
||||
CombinedCategoryPlot plot = new CombinedCategoryPlot(
|
||||
domainAxis, new NumberAxis("Range"));
|
||||
plot.add(subplot1, 2);
|
||||
plot.add(subplot2, 1);
|
||||
|
||||
JFreeChart result = new JFreeChart(
|
||||
"Combined Domain Category Plot Demo",
|
||||
new Font("SansSerif", Font.BOLD, 12), plot, true);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a panel for the demo (used by SuperDemo.java).
|
||||
*
|
||||
* @return A panel.
|
||||
*/
|
||||
public static JPanel createDemoPanel() {
|
||||
JFreeChart chart = createChart();
|
||||
return new ChartPanel(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starting point for the demonstration application.
|
||||
*
|
||||
* @param args ignored.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
String title = "Combined Category Plot Demo 1";
|
||||
CombinedCategoryPlotDemo1 demo = new CombinedCategoryPlotDemo1(title);
|
||||
demo.pack();
|
||||
RefineryUtilities.centerFrameOnScreen(demo);
|
||||
demo.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,262 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ------------------------
|
||||
* CombinedXYPlotDemo1.java
|
||||
* ------------------------
|
||||
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): ;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 05-May-2008 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.experimental.chart.demo;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Paint;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.jfree.chart.ChartPanel;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
import org.jfree.chart.axis.DateAxis;
|
||||
import org.jfree.chart.axis.NumberAxis;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.labels.StandardXYToolTipGenerator;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.chart.renderer.xy.XYBarRenderer;
|
||||
import org.jfree.chart.renderer.xy.XYItemRenderer;
|
||||
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
|
||||
import org.jfree.chart.title.LegendTitle;
|
||||
import org.jfree.data.time.Month;
|
||||
import org.jfree.data.time.TimeSeries;
|
||||
import org.jfree.data.time.TimeSeriesCollection;
|
||||
import org.jfree.data.xy.IntervalXYDataset;
|
||||
import org.jfree.data.xy.XYDataset;
|
||||
import org.jfree.experimental.chart.plot.CombinedXYPlot;
|
||||
import org.jfree.ui.ApplicationFrame;
|
||||
import org.jfree.ui.RefineryUtilities;
|
||||
|
||||
/**
|
||||
* A demonstration application showing a {@link CombinedXYPlot} with
|
||||
* two subplots.
|
||||
*/
|
||||
public class CombinedXYPlotDemo1 extends ApplicationFrame {
|
||||
|
||||
/**
|
||||
* Constructs a new demonstration application.
|
||||
*
|
||||
* @param title the frame title.
|
||||
*/
|
||||
public CombinedXYPlotDemo1(String title) {
|
||||
super(title);
|
||||
JPanel panel = createDemoPanel();
|
||||
panel.setPreferredSize(new java.awt.Dimension(500, 270));
|
||||
setContentPane(panel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an overlaid chart.
|
||||
*
|
||||
* @return The chart.
|
||||
*/
|
||||
private static JFreeChart createCombinedChart() {
|
||||
|
||||
// create plot ...
|
||||
IntervalXYDataset data1 = createDataset1();
|
||||
XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
|
||||
renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
|
||||
StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
|
||||
new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
|
||||
renderer1.setSeriesStroke(0, new BasicStroke(4.0f,
|
||||
BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
|
||||
renderer1.setSeriesPaint(0, Color.blue);
|
||||
|
||||
DateAxis domainAxis = new DateAxis("Year");
|
||||
domainAxis.setLowerMargin(0.0);
|
||||
domainAxis.setUpperMargin(0.02);
|
||||
ValueAxis rangeAxis = new NumberAxis("$billion");
|
||||
XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1);
|
||||
plot1.setBackgroundPaint(Color.lightGray);
|
||||
plot1.setDomainGridlinePaint(Color.white);
|
||||
plot1.setRangeGridlinePaint(Color.white);
|
||||
|
||||
// add a second dataset and renderer...
|
||||
IntervalXYDataset data2 = createDataset2();
|
||||
XYBarRenderer renderer2 = new XYBarRenderer() {
|
||||
public Paint getItemPaint(int series, int item) {
|
||||
XYDataset dataset = getPlot().getDataset();
|
||||
if (dataset.getYValue(series, item) >= 0.0) {
|
||||
return Color.red;
|
||||
}
|
||||
else {
|
||||
return Color.green;
|
||||
}
|
||||
}
|
||||
};
|
||||
renderer2.setSeriesPaint(0, Color.red);
|
||||
renderer2.setDrawBarOutline(false);
|
||||
renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
|
||||
StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
|
||||
new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
|
||||
|
||||
XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"),
|
||||
renderer2);
|
||||
plot2.setBackgroundPaint(Color.lightGray);
|
||||
plot2.setDomainGridlinePaint(Color.white);
|
||||
plot2.setRangeGridlinePaint(Color.white);
|
||||
|
||||
CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis);
|
||||
cplot.add(plot1, 3);
|
||||
cplot.add(plot2, 2);
|
||||
cplot.setGap(8.0);
|
||||
cplot.setDomainGridlinePaint(Color.white);
|
||||
cplot.setDomainGridlinesVisible(true);
|
||||
|
||||
// return a new chart containing the overlaid plot...
|
||||
JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1",
|
||||
JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
|
||||
chart.setBackgroundPaint(Color.white);
|
||||
LegendTitle legend = new LegendTitle(cplot);
|
||||
chart.addSubtitle(legend);
|
||||
return chart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a sample dataset. You wouldn't normally hard-code the
|
||||
* population of a dataset in this way (it would be better to read the
|
||||
* values from a file or a database query), but for a self-contained demo
|
||||
* this is the least complicated solution.
|
||||
*
|
||||
* @return The dataset.
|
||||
*/
|
||||
private static IntervalXYDataset createDataset1() {
|
||||
|
||||
// create dataset 1...
|
||||
TimeSeries series1 = new TimeSeries("Series 1", Month.class);
|
||||
series1.add(new Month(1, 2005), 7627.743);
|
||||
series1.add(new Month(2, 2005), 7713.138);
|
||||
series1.add(new Month(3, 2005), 6776.939);
|
||||
series1.add(new Month(4, 2005), 5764.537);
|
||||
series1.add(new Month(5, 2005), 4777.880);
|
||||
series1.add(new Month(6, 2005), 4836.496);
|
||||
series1.add(new Month(7, 2005), 3887.618);
|
||||
series1.add(new Month(8, 2005), 3926.933);
|
||||
series1.add(new Month(9, 2005), 4932.710);
|
||||
series1.add(new Month(10, 2005), 4027.123);
|
||||
series1.add(new Month(11, 2005), 8092.322);
|
||||
series1.add(new Month(12, 2005), 8170.414);
|
||||
series1.add(new Month(1, 2006), 8196.070);
|
||||
series1.add(new Month(2, 2006), 8269.886);
|
||||
series1.add(new Month(3, 2006), 5371.156);
|
||||
series1.add(new Month(4, 2006), 5355.718);
|
||||
series1.add(new Month(5, 2006), 5356.777);
|
||||
series1.add(new Month(6, 2006), 8420.042);
|
||||
series1.add(new Month(7, 2006), 8444.347);
|
||||
series1.add(new Month(8, 2006), 8515.034);
|
||||
series1.add(new Month(9, 2006), 8506.974);
|
||||
series1.add(new Month(10, 2006), 8584.329);
|
||||
series1.add(new Month(11, 2006), 8633.246);
|
||||
series1.add(new Month(12, 2006), 8680.224);
|
||||
series1.add(new Month(1, 2007), 8707.561);
|
||||
return new TimeSeriesCollection(series1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a sample dataset. You wouldn't normally hard-code the
|
||||
* population of a dataset in this way (it would be better to read the
|
||||
* values from a file or a database query), but for a self-contained demo
|
||||
* this is the least complicated solution.
|
||||
*
|
||||
* @return A sample dataset.
|
||||
*/
|
||||
private static IntervalXYDataset createDataset2() {
|
||||
TimeSeriesCollection dataset = new TimeSeriesCollection();
|
||||
|
||||
TimeSeries series1 = new TimeSeries("Series 2", Month.class);
|
||||
series1.add(new Month(1, 2005), 1200);
|
||||
series1.add(new Month(2, 2005), 1400);
|
||||
series1.add(new Month(3, 2005), 1500);
|
||||
series1.add(new Month(4, 2005), 1700);
|
||||
series1.add(new Month(5, 2005), 1600);
|
||||
series1.add(new Month(6, 2005), 2400);
|
||||
series1.add(new Month(7, 2005), 2100);
|
||||
series1.add(new Month(8, 2005), 2200);
|
||||
series1.add(new Month(9, 2005), 800);
|
||||
series1.add(new Month(10, 2005), 2350);
|
||||
series1.add(new Month(11, 2005), 500);
|
||||
series1.add(new Month(12, 2005), 700);
|
||||
series1.add(new Month(1, 2006), 900);
|
||||
series1.add(new Month(2, 2006), 1500);
|
||||
series1.add(new Month(3, 2006), 2100);
|
||||
series1.add(new Month(4, 2006), 2200);
|
||||
series1.add(new Month(5, 2006), 1900);
|
||||
series1.add(new Month(6, 2006), 3000);
|
||||
series1.add(new Month(7, 2006), 3780);
|
||||
series1.add(new Month(8, 2006), 4000);
|
||||
series1.add(new Month(9, 2006), 4500);
|
||||
series1.add(new Month(10, 2006), 7000);
|
||||
series1.add(new Month(11, 2006), 5500);
|
||||
series1.add(new Month(12, 2006), 6000);
|
||||
series1.add(new Month(1, 2007), 6500);
|
||||
dataset.addSeries(series1);
|
||||
return dataset;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a panel for the demo (used by SuperDemo.java).
|
||||
*
|
||||
* @return A panel.
|
||||
*/
|
||||
public static JPanel createDemoPanel() {
|
||||
JFreeChart chart = createCombinedChart();
|
||||
return new ChartPanel(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starting point for the demonstration application.
|
||||
*
|
||||
* @param args ignored.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
CombinedXYPlotDemo1 demo = new CombinedXYPlotDemo1(
|
||||
"JFreeChart : CombinedXYPlotDemo1");
|
||||
demo.pack();
|
||||
RefineryUtilities.centerFrameOnScreen(demo);
|
||||
demo.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------------
|
||||
* CombinedCategoryPlot.java
|
||||
* -------------------------
|
||||
* (C) Copyright 2008, by Richard West and Contributors.
|
||||
*
|
||||
* Original Author: Richard West, Advanced Micro Devices, Inc.;
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 02-Feb-2007 : Version 1, contributed by Richard West - see
|
||||
* patch 1924543 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.experimental.chart.plot;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.jfree.chart.axis.CategoryAxis;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.plot.CombinedDomainCategoryPlot;
|
||||
import org.jfree.data.Range;
|
||||
|
||||
/**
|
||||
* A specialised form of {@link CombinedDomainCategoryPlot} where the
|
||||
* subplots share not only the same x-axis, but also the same y-axis.
|
||||
*/
|
||||
public class CombinedCategoryPlot extends CombinedDomainCategoryPlot {
|
||||
|
||||
/**
|
||||
* Creates a new instance with the specified axes.
|
||||
*
|
||||
* @param domainAxis the x-axis.
|
||||
* @param rangeAxis the y-axis.
|
||||
*/
|
||||
public CombinedCategoryPlot (CategoryAxis domainAxis, ValueAxis rangeAxis) {
|
||||
super(domainAxis);
|
||||
super.setGap(10.0);
|
||||
super.setRangeAxis(rangeAxis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new subplot with weight <code>1</code>.
|
||||
*
|
||||
* @param subplot the subplot.
|
||||
*/
|
||||
public void add(CategoryPlot subplot) {
|
||||
this.add(subplot, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new subplot with the specified weight.
|
||||
*
|
||||
* @param subplot the subplot.
|
||||
* @param weight the weight for the subplot.
|
||||
*/
|
||||
public void add(CategoryPlot subplot, int weight) {
|
||||
super.add(subplot, weight);
|
||||
|
||||
ValueAxis l_range = super.getRangeAxis();
|
||||
subplot.setRangeAxis(0, l_range, false);
|
||||
|
||||
super.setRangeAxis(l_range);
|
||||
if (null == l_range) {
|
||||
return;
|
||||
}
|
||||
|
||||
l_range.configure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounds of the data values that will be plotted against
|
||||
* the specified axis.
|
||||
*
|
||||
* @param axis the axis.
|
||||
*
|
||||
* @return The bounds.
|
||||
*/
|
||||
public Range getDataRange(ValueAxis axis) {
|
||||
Range l_result = null;
|
||||
Iterator l_itr = getSubplots().iterator();
|
||||
while (l_itr.hasNext()) {
|
||||
CategoryPlot l_subplot = (CategoryPlot) l_itr.next();
|
||||
|
||||
l_result = Range.combine(l_result, l_subplot.getDataRange(axis));
|
||||
}
|
||||
return l_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the range axis that is shared by all the subplots.
|
||||
*
|
||||
* @param axis the axis.
|
||||
*/
|
||||
public void setRangeAxis(ValueAxis axis) {
|
||||
Iterator l_itr = getSubplots().iterator();
|
||||
while (l_itr.hasNext()) {
|
||||
CategoryPlot l_subplot = (CategoryPlot) l_itr.next();
|
||||
l_subplot.setRangeAxis(0, axis, false);
|
||||
}
|
||||
|
||||
super.setRangeAxis(axis);
|
||||
if (null == axis) {
|
||||
return;
|
||||
}
|
||||
|
||||
axis.configure();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------
|
||||
* CombinedXYPlot.java
|
||||
* -------------------
|
||||
* (C) Copyright 2008, by Richard West and Contributors.
|
||||
*
|
||||
* Original Author: Richard West, Advanced Micro Devices, Inc.;
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 05-May-2008 : Version 1, contributed by Richard West - see
|
||||
* patch 1924543 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.experimental.chart.plot;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.CombinedDomainCategoryPlot;
|
||||
import org.jfree.chart.plot.CombinedDomainXYPlot;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.data.Range;
|
||||
|
||||
/**
|
||||
* A specialised form of {@link CombinedDomainCategoryPlot} where the
|
||||
* subplots share not only the same x-axis, but also the same y-axis.
|
||||
*/
|
||||
public class CombinedXYPlot extends CombinedDomainXYPlot {
|
||||
|
||||
/**
|
||||
* Creates a new instance with the specified axes.
|
||||
*
|
||||
* @param domainAxis the x-axis.
|
||||
* @param rangeAxis the y-axis.
|
||||
*/
|
||||
public CombinedXYPlot(ValueAxis domainAxis, ValueAxis rangeAxis) {
|
||||
super(domainAxis);
|
||||
super.setGap(10.0);
|
||||
super.setRangeAxis(rangeAxis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new subplot with weight <code>1</code>.
|
||||
*
|
||||
* @param subplot the subplot.
|
||||
*/
|
||||
public void add(XYPlot subplot) {
|
||||
this.add(subplot, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new subplot with the specified weight.
|
||||
*
|
||||
* @param subplot the subplot.
|
||||
* @param weight the weight for the subplot.
|
||||
*/
|
||||
public void add(XYPlot subplot, int weight) {
|
||||
super.add(subplot, weight);
|
||||
|
||||
ValueAxis l_range = super.getRangeAxis();
|
||||
subplot.setRangeAxis(0, l_range, false);
|
||||
|
||||
super.setRangeAxis(l_range);
|
||||
if (null == l_range) {
|
||||
return;
|
||||
}
|
||||
|
||||
l_range.configure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounds of the data values that will be plotted against
|
||||
* the specified axis.
|
||||
*
|
||||
* @param axis the axis.
|
||||
*
|
||||
* @return The bounds.
|
||||
*/
|
||||
public Range getDataRange(ValueAxis axis) {
|
||||
Range l_result = null;
|
||||
Iterator l_itr = getSubplots().iterator();
|
||||
while (l_itr.hasNext()) {
|
||||
XYPlot l_subplot = (XYPlot) l_itr.next();
|
||||
|
||||
l_result = Range.combine(l_result, l_subplot.getDataRange(axis));
|
||||
}
|
||||
return l_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the range axis that is shared by all the subplots.
|
||||
*
|
||||
* @param axis the axis.
|
||||
*/
|
||||
public void setRangeAxis(ValueAxis axis) {
|
||||
Iterator l_itr = getSubplots().iterator();
|
||||
while (l_itr.hasNext()) {
|
||||
XYPlot l_subplot = (XYPlot) l_itr.next();
|
||||
l_subplot.setRangeAxis(0, axis, false);
|
||||
}
|
||||
|
||||
super.setRangeAxis(axis);
|
||||
if (null == axis) {
|
||||
return;
|
||||
}
|
||||
|
||||
axis.configure();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,298 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------------------------
|
||||
* XYSmoothLineAndShapeRenderer.java
|
||||
* ---------------------------------
|
||||
* (C) Copyright 2007, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: -;
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 14-Jun-2007 : Version 1;
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.experimental.chart.renderer.xy;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.entity.EntityCollection;
|
||||
import org.jfree.chart.plot.CrosshairState;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.chart.renderer.xy.XYItemRendererState;
|
||||
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
|
||||
import org.jfree.data.xy.XYDataset;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
|
||||
/**
|
||||
* A line and shape renderer that performs line smoothing. See
|
||||
* http://www.jfree.org/phpBB2/viewtopic.php?t=20671
|
||||
*
|
||||
* WARNING: THIS CLASS IS NOT PART OF THE STANDARD JFREECHART API AND IS
|
||||
* SUBJECT TO ALTERATION OR REMOVAL. DO NOT RELY ON THIS CLASS FOR
|
||||
* PRODUCTION USE. Please experiment with this code and provide feedback.
|
||||
*/
|
||||
public class XYSmoothLineAndShapeRenderer extends XYLineAndShapeRenderer {
|
||||
|
||||
/**
|
||||
* Draws the item (first pass). This method draws the lines
|
||||
* connecting the items.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param state the renderer state.
|
||||
* @param dataArea the area within which the data is being drawn.
|
||||
* @param plot the plot (can be used to obtain standard color
|
||||
* information etc).
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param dataset the dataset.
|
||||
* @param pass the pass.
|
||||
* @param series the series index (zero-based).
|
||||
* @param item the item index (zero-based).
|
||||
*/
|
||||
protected void drawPrimaryLine(XYItemRendererState state, Graphics2D g2,
|
||||
XYPlot plot, XYDataset dataset, int pass, int series, int item,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea) {
|
||||
|
||||
if (item == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get the data point...
|
||||
double x1 = dataset.getXValue(series, item);
|
||||
double y1 = dataset.getYValue(series, item);
|
||||
if (Double.isNaN(y1) || Double.isNaN(x1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double x0 = dataset.getXValue(series, item - 1);
|
||||
double y0 = dataset.getYValue(series, item - 1);
|
||||
if (Double.isNaN(y0) || Double.isNaN(x0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
|
||||
RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
|
||||
|
||||
double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation);
|
||||
double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation);
|
||||
|
||||
double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
|
||||
double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);
|
||||
|
||||
// only draw if we have good values
|
||||
if (Double.isNaN(transX0) || Double.isNaN(transY0)
|
||||
|| Double.isNaN(transX1) || Double.isNaN(transY1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Point2D.Double point0 = new Point2D.Double();
|
||||
Point2D.Double point1 = new Point2D.Double();
|
||||
Point2D.Double point2 = new Point2D.Double();
|
||||
Point2D.Double point3 = new Point2D.Double();
|
||||
|
||||
if (item == 1) {
|
||||
point0 = null;
|
||||
}
|
||||
else {
|
||||
point0.x = domainAxis.valueToJava2D(dataset.getXValue(series,
|
||||
item - 2), dataArea, xAxisLocation);
|
||||
point0.y = rangeAxis.valueToJava2D(dataset.getYValue(series,
|
||||
item - 2), dataArea, yAxisLocation);
|
||||
}
|
||||
|
||||
point1.x = transX0;
|
||||
point1.y = transY0;
|
||||
|
||||
point2.x = transX1;
|
||||
point2.y = transY1;
|
||||
|
||||
if ((item + 1) == dataset.getItemCount(series)) {
|
||||
point3 = null;
|
||||
}
|
||||
else {
|
||||
point3.x = domainAxis.valueToJava2D(dataset.getXValue(series,
|
||||
item + 1), dataArea, xAxisLocation);
|
||||
point3.y = rangeAxis.valueToJava2D(dataset.getYValue(series,
|
||||
item + 1), dataArea, yAxisLocation);
|
||||
}
|
||||
|
||||
int steps = ((int) ((point2.x - point1.x) / 0.2) < 30)
|
||||
? (int) ((point2.x - point1.x) / 0.2) : 30;
|
||||
|
||||
Point2D.Double[] points = getBezierCurve(point0, point1, point2,
|
||||
point3, 1, steps);
|
||||
|
||||
for (int i = 1; i < points.length; i++) {
|
||||
transX0 = points[i - 1].x;
|
||||
transY0 = points[i - 1].y;
|
||||
transX1 = points[i].x;
|
||||
transY1 = points[i].y;
|
||||
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
state.workingLine.setLine(transY0, transX0, transY1, transX1);
|
||||
}
|
||||
else if (orientation == PlotOrientation.VERTICAL) {
|
||||
state.workingLine.setLine(transX0, transY0, transX1, transY1);
|
||||
}
|
||||
|
||||
if (state.workingLine.intersects(dataArea)) {
|
||||
drawFirstPassShape(g2, pass, series, item, state.workingLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the item shapes and adds chart entities (second pass). This method
|
||||
* draws the shapes which mark the item positions. If <code>entities</code>
|
||||
* is not <code>null</code> it will be populated with entity information
|
||||
* for points that fall within the data area.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot (can be used to obtain standard color
|
||||
* information etc).
|
||||
* @param domainAxis the domain axis.
|
||||
* @param dataArea the area within which the data is being drawn.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param dataset the dataset.
|
||||
* @param pass the pass.
|
||||
* @param series the series index (zero-based).
|
||||
* @param item the item index (zero-based).
|
||||
* @param crosshairState the crosshair state.
|
||||
* @param entities the entity collection.
|
||||
*/
|
||||
protected void drawSecondaryPass(Graphics2D g2, XYPlot plot,
|
||||
XYDataset dataset, int pass, int series, int item,
|
||||
ValueAxis domainAxis, Rectangle2D dataArea,
|
||||
ValueAxis rangeAxis, CrosshairState crosshairState,
|
||||
EntityCollection entities) {
|
||||
// super.drawSecondaryPass(g2, plot, dataset, pass, series, item,
|
||||
// domainAxis, dataArea, rangeAxis, crosshairState, entities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the control points.
|
||||
*
|
||||
* @param point0
|
||||
* @param point1
|
||||
* @param point2
|
||||
* @param point3
|
||||
* @param control1
|
||||
* @param control2
|
||||
* @param smooth
|
||||
*/
|
||||
public static void getControlPoints(Point2D.Double point0,
|
||||
Point2D.Double point1, Point2D.Double point2,
|
||||
Point2D.Double point3, Point2D.Double control1,
|
||||
Point2D.Double control2, double smooth) {
|
||||
|
||||
// Reference: http://www.antigrain.com/research/bezier_interpolation/
|
||||
|
||||
if (point0 == null) point0 = point1; //new Point2D.Double(0, 0);
|
||||
if (point3 == null) point3 = point2; //new Point2D.Double(0, 0);
|
||||
|
||||
Point2D.Double c1 = new Point2D.Double(
|
||||
(point0.x + point1.x) / 2.0, (point0.y + point1.y) / 2.0);
|
||||
Point2D.Double c2 = new Point2D.Double(
|
||||
(point1.x + point2.x) / 2.0, (point1.y + point2.y) / 2.0);
|
||||
Point2D.Double c3 = new Point2D.Double(
|
||||
(point2.x + point3.x) / 2.0, (point2.y + point3.y) / 2.0);
|
||||
|
||||
double len1 = point1.distance(point0);
|
||||
double len2 = point2.distance(point1);
|
||||
double len3 = point3.distance(point2);
|
||||
|
||||
double k1 = len1 / (len1 + len2);
|
||||
double k2 = len2 / (len2 + len3);
|
||||
|
||||
Point2D.Double m1 = new Point2D.Double(
|
||||
c1.x + (c2.x - c1.x) * k1, c1.y + (c2.y - c1.y) * k1);
|
||||
Point2D.Double m2 = new Point2D.Double(
|
||||
c2.x + (c3.x - c2.x) * k2, c2.y + (c3.y - c2.y) * k2);
|
||||
|
||||
control1.setLocation(new Point2D.Double(
|
||||
m1.x + (c2.x - m1.x) * smooth + point1.x - m1.x,
|
||||
m1.y + (c2.y - m1.y) * smooth + point1.y - m1.y));
|
||||
control2.setLocation(new Point2D.Double(
|
||||
m2.x + (c2.x - m2.x) * smooth + point2.x - m2.x,
|
||||
m2.y + (c2.y - m2.y) * smooth + point2.y - m2.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the points for a bezier curve.
|
||||
*
|
||||
* @param point0
|
||||
* @param point1
|
||||
* @param point2
|
||||
* @param point3
|
||||
* @param smooth
|
||||
* @param steps
|
||||
*
|
||||
* @return The curve points.
|
||||
*/
|
||||
public static Point2D.Double[] getBezierCurve(Point2D.Double point0,
|
||||
Point2D.Double point1, Point2D.Double point2,
|
||||
Point2D.Double point3, double smooth, int steps) {
|
||||
Point2D.Double control1 = new Point2D.Double();
|
||||
Point2D.Double control2 = new Point2D.Double();
|
||||
|
||||
getControlPoints(point0, point1, point2, point3, control1, control2,
|
||||
smooth);
|
||||
|
||||
Point2D.Double C = new Point2D.Double(
|
||||
3 * (control1.x - point1.x), 3 * (control1.y - point1.y));
|
||||
Point2D.Double B = new Point2D.Double(3 * (control2.x - control1.x)
|
||||
- C.x, 3 * (control2.y - control1.y) - C.y);
|
||||
Point2D.Double A = new Point2D.Double(point2.x - point1.x - C.x - B.x,
|
||||
point2.y - point1.y - C.y - B.y);
|
||||
|
||||
Point2D.Double[] res = new Point2D.Double[steps + 1];
|
||||
double stepSize = 1.0 / steps;
|
||||
double step = stepSize;
|
||||
|
||||
res[0] = point1;
|
||||
for (int i = 1; i < steps; i++) {
|
||||
res[i] = new Point2D.Double(A.x * Math.pow(step, 3) + B.x
|
||||
* Math.pow(step, 2) + C.x * step + point1.x, A.y
|
||||
* Math.pow(step, 3) + B.y * Math.pow(step, 2) + C.y * step
|
||||
+ point1.y);
|
||||
//System.out.println(step + " : " + res[i]);
|
||||
step += stepSize;
|
||||
}
|
||||
res[steps] = point2;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,189 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------
|
||||
* ChartColor.java
|
||||
* ---------------
|
||||
* (C) Copyright 2003-2008, by Cameron Riley and Contributors.
|
||||
*
|
||||
* Original Author: Cameron Riley;
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 23-Jan-2003 : Version 1, contributed by Cameron Riley (DG);
|
||||
* 25-Nov-2004 : Changed first 7 colors to softer shades (DG);
|
||||
* 03-Nov-2005 : Removed orange color, too close to yellow - see bug
|
||||
* report 1328408 (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Paint;
|
||||
|
||||
/**
|
||||
* Class to extend the number of Colors available to the charts. This
|
||||
* extends the java.awt.Color object and extends the number of final
|
||||
* Colors publically accessible.
|
||||
*/
|
||||
public class ChartColor extends Color {
|
||||
|
||||
/** A very dark red color. */
|
||||
public static final Color VERY_DARK_RED = new Color(0x80, 0x00, 0x00);
|
||||
|
||||
/** A dark red color. */
|
||||
public static final Color DARK_RED = new Color(0xc0, 0x00, 0x00);
|
||||
|
||||
/** A light red color. */
|
||||
public static final Color LIGHT_RED = new Color(0xFF, 0x40, 0x40);
|
||||
|
||||
/** A very light red color. */
|
||||
public static final Color VERY_LIGHT_RED = new Color(0xFF, 0x80, 0x80);
|
||||
|
||||
/** A very dark yellow color. */
|
||||
public static final Color VERY_DARK_YELLOW = new Color(0x80, 0x80, 0x00);
|
||||
|
||||
/** A dark yellow color. */
|
||||
public static final Color DARK_YELLOW = new Color(0xC0, 0xC0, 0x00);
|
||||
|
||||
/** A light yellow color. */
|
||||
public static final Color LIGHT_YELLOW = new Color(0xFF, 0xFF, 0x40);
|
||||
|
||||
/** A very light yellow color. */
|
||||
public static final Color VERY_LIGHT_YELLOW = new Color(0xFF, 0xFF, 0x80);
|
||||
|
||||
/** A very dark green color. */
|
||||
public static final Color VERY_DARK_GREEN = new Color(0x00, 0x80, 0x00);
|
||||
|
||||
/** A dark green color. */
|
||||
public static final Color DARK_GREEN = new Color(0x00, 0xC0, 0x00);
|
||||
|
||||
/** A light green color. */
|
||||
public static final Color LIGHT_GREEN = new Color(0x40, 0xFF, 0x40);
|
||||
|
||||
/** A very light green color. */
|
||||
public static final Color VERY_LIGHT_GREEN = new Color(0x80, 0xFF, 0x80);
|
||||
|
||||
/** A very dark cyan color. */
|
||||
public static final Color VERY_DARK_CYAN = new Color(0x00, 0x80, 0x80);
|
||||
|
||||
/** A dark cyan color. */
|
||||
public static final Color DARK_CYAN = new Color(0x00, 0xC0, 0xC0);
|
||||
|
||||
/** A light cyan color. */
|
||||
public static final Color LIGHT_CYAN = new Color(0x40, 0xFF, 0xFF);
|
||||
|
||||
/** Aa very light cyan color. */
|
||||
public static final Color VERY_LIGHT_CYAN = new Color(0x80, 0xFF, 0xFF);
|
||||
|
||||
/** A very dark blue color. */
|
||||
public static final Color VERY_DARK_BLUE = new Color(0x00, 0x00, 0x80);
|
||||
|
||||
/** A dark blue color. */
|
||||
public static final Color DARK_BLUE = new Color(0x00, 0x00, 0xC0);
|
||||
|
||||
/** A light blue color. */
|
||||
public static final Color LIGHT_BLUE = new Color(0x40, 0x40, 0xFF);
|
||||
|
||||
/** A very light blue color. */
|
||||
public static final Color VERY_LIGHT_BLUE = new Color(0x80, 0x80, 0xFF);
|
||||
|
||||
/** A very dark magenta/purple color. */
|
||||
public static final Color VERY_DARK_MAGENTA = new Color(0x80, 0x00, 0x80);
|
||||
|
||||
/** A dark magenta color. */
|
||||
public static final Color DARK_MAGENTA = new Color(0xC0, 0x00, 0xC0);
|
||||
|
||||
/** A light magenta color. */
|
||||
public static final Color LIGHT_MAGENTA = new Color(0xFF, 0x40, 0xFF);
|
||||
|
||||
/** A very light magenta color. */
|
||||
public static final Color VERY_LIGHT_MAGENTA = new Color(0xFF, 0x80, 0xFF);
|
||||
|
||||
/**
|
||||
* Creates a Color with an opaque sRGB with red, green and blue values in
|
||||
* range 0-255.
|
||||
*
|
||||
* @param r the red component in range 0x00-0xFF.
|
||||
* @param g the green component in range 0x00-0xFF.
|
||||
* @param b the blue component in range 0x00-0xFF.
|
||||
*/
|
||||
public ChartColor(int r, int g, int b) {
|
||||
super(r, g, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to return an array of <code>Paint</code> objects that
|
||||
* represent the pre-defined colors in the <code>Color<code> and
|
||||
* <code>ChartColor</code> objects.
|
||||
*
|
||||
* @return An array of objects with the <code>Paint</code> interface.
|
||||
*/
|
||||
public static Paint[] createDefaultPaintArray() {
|
||||
|
||||
return new Paint[] {
|
||||
new Color(0xFF, 0x55, 0x55),
|
||||
new Color(0x55, 0x55, 0xFF),
|
||||
new Color(0x55, 0xFF, 0x55),
|
||||
new Color(0xFF, 0xFF, 0x55),
|
||||
new Color(0xFF, 0x55, 0xFF),
|
||||
new Color(0x55, 0xFF, 0xFF),
|
||||
Color.pink,
|
||||
Color.gray,
|
||||
ChartColor.DARK_RED,
|
||||
ChartColor.DARK_BLUE,
|
||||
ChartColor.DARK_GREEN,
|
||||
ChartColor.DARK_YELLOW,
|
||||
ChartColor.DARK_MAGENTA,
|
||||
ChartColor.DARK_CYAN,
|
||||
Color.darkGray,
|
||||
ChartColor.LIGHT_RED,
|
||||
ChartColor.LIGHT_BLUE,
|
||||
ChartColor.LIGHT_GREEN,
|
||||
ChartColor.LIGHT_YELLOW,
|
||||
ChartColor.LIGHT_MAGENTA,
|
||||
ChartColor.LIGHT_CYAN,
|
||||
Color.lightGray,
|
||||
ChartColor.VERY_DARK_RED,
|
||||
ChartColor.VERY_DARK_BLUE,
|
||||
ChartColor.VERY_DARK_GREEN,
|
||||
ChartColor.VERY_DARK_YELLOW,
|
||||
ChartColor.VERY_DARK_MAGENTA,
|
||||
ChartColor.VERY_DARK_CYAN,
|
||||
ChartColor.VERY_LIGHT_RED,
|
||||
ChartColor.VERY_LIGHT_BLUE,
|
||||
ChartColor.VERY_LIGHT_GREEN,
|
||||
ChartColor.VERY_LIGHT_YELLOW,
|
||||
ChartColor.VERY_LIGHT_MAGENTA,
|
||||
ChartColor.VERY_LIGHT_CYAN
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,96 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------
|
||||
* ChartFrame.java
|
||||
* ---------------
|
||||
* (C) Copyright 2001-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 22-Nov-2001 : Version 1 (DG);
|
||||
* 08-Jan-2001 : Added chartPanel attribute (DG);
|
||||
* 24-May-2002 : Renamed JFreeChartFrame --> ChartFrame (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
/**
|
||||
* A frame for displaying a chart.
|
||||
*/
|
||||
public class ChartFrame extends JFrame {
|
||||
|
||||
/** The chart panel. */
|
||||
private ChartPanel chartPanel;
|
||||
|
||||
/**
|
||||
* Constructs a frame for a chart.
|
||||
*
|
||||
* @param title the frame title.
|
||||
* @param chart the chart.
|
||||
*/
|
||||
public ChartFrame(String title, JFreeChart chart) {
|
||||
this(title, chart, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a frame for a chart.
|
||||
*
|
||||
* @param title the frame title.
|
||||
* @param chart the chart.
|
||||
* @param scrollPane if <code>true</code>, put the Chart(Panel) into a
|
||||
* JScrollPane.
|
||||
*/
|
||||
public ChartFrame(String title, JFreeChart chart, boolean scrollPane) {
|
||||
super(title);
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
this.chartPanel = new ChartPanel(chart);
|
||||
if (scrollPane) {
|
||||
setContentPane(new JScrollPane(this.chartPanel));
|
||||
}
|
||||
else {
|
||||
setContentPane(this.chartPanel);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart panel for the frame.
|
||||
*
|
||||
* @return The chart panel.
|
||||
*/
|
||||
public ChartPanel getChartPanel() {
|
||||
return this.chartPanel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* --------------------
|
||||
* ChartMouseEvent.java
|
||||
* --------------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Alex Weber;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 27-May-2002 : Version 1, incorporating code and ideas by Alex Weber (DG);
|
||||
* 13-Jun-2002 : Added Javadoc comments (DG);
|
||||
* 26-Sep-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 05-Nov-2002 : Added a reference to the source chart (DG);
|
||||
* 13-Jul-2004 : Now extends EventObject and implements Serializable (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 24-May-2007 : Updated API docs (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.Serializable;
|
||||
import java.util.EventObject;
|
||||
|
||||
import org.jfree.chart.entity.ChartEntity;
|
||||
|
||||
/**
|
||||
* A mouse event for a chart that is displayed in a {@link ChartPanel}.
|
||||
*
|
||||
* @see ChartMouseListener
|
||||
*/
|
||||
public class ChartMouseEvent extends EventObject implements Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -682393837314562149L;
|
||||
|
||||
/** The chart that the mouse event relates to. */
|
||||
private JFreeChart chart;
|
||||
|
||||
/** The Java mouse event that triggered this event. */
|
||||
private MouseEvent trigger;
|
||||
|
||||
/** The chart entity (if any). */
|
||||
private ChartEntity entity;
|
||||
|
||||
/**
|
||||
* Constructs a new event.
|
||||
*
|
||||
* @param chart the source chart (<code>null</code> not permitted).
|
||||
* @param trigger the mouse event that triggered this event
|
||||
* (<code>null</code> not permitted).
|
||||
* @param entity the chart entity (if any) under the mouse point
|
||||
* (<code>null</code> permitted).
|
||||
*/
|
||||
public ChartMouseEvent(JFreeChart chart, MouseEvent trigger,
|
||||
ChartEntity entity) {
|
||||
super(chart);
|
||||
this.chart = chart;
|
||||
this.trigger = trigger;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart that the mouse event relates to.
|
||||
*
|
||||
* @return The chart (never <code>null</code>).
|
||||
*/
|
||||
public JFreeChart getChart() {
|
||||
return this.chart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mouse event that triggered this event.
|
||||
*
|
||||
* @return The event (never <code>null</code>).
|
||||
*/
|
||||
public MouseEvent getTrigger() {
|
||||
return this.trigger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart entity (if any) under the mouse point.
|
||||
*
|
||||
* @return The chart entity (possibly <code>null</code>).
|
||||
*/
|
||||
public ChartEntity getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -----------------------
|
||||
* ChartMouseListener.java
|
||||
* -----------------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Alex Weber;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 27-May-2002 : Version 1, incorporating code and ideas by Alex Weber (DG);
|
||||
* 13-Jun-2002 : Added Javadocs (DG);
|
||||
* 26-Sep-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 23-Nov-2005 : Now extends EventListener (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 24-May-2007 : Updated API docs (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* The interface that must be implemented by classes that wish to receive
|
||||
* {@link ChartMouseEvent} notifications from a {@link ChartPanel}.
|
||||
*
|
||||
* @see ChartPanel#addChartMouseListener(ChartMouseListener)
|
||||
*/
|
||||
public interface ChartMouseListener extends EventListener {
|
||||
|
||||
/**
|
||||
* Callback method for receiving notification of a mouse click on a chart.
|
||||
*
|
||||
* @param event information about the event.
|
||||
*/
|
||||
void chartMouseClicked(ChartMouseEvent event);
|
||||
|
||||
/**
|
||||
* Callback method for receiving notification of a mouse movement on a
|
||||
* chart.
|
||||
*
|
||||
* @param event information about the event.
|
||||
*/
|
||||
void chartMouseMoved(ChartMouseEvent event);
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,255 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -----------------------
|
||||
* ChartRenderingInfo.java
|
||||
* -----------------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 22-Jan-2002 : Version 1 (DG);
|
||||
* 05-Feb-2002 : Added a new constructor, completed Javadoc comments (DG);
|
||||
* 05-Mar-2002 : Added a clear() method (DG);
|
||||
* 23-May-2002 : Renamed DrawInfo --> ChartRenderingInfo (DG);
|
||||
* 26-Sep-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 17-Sep-2003 : Added PlotRenderingInfo (DG);
|
||||
* 01-Nov-2005 : Updated equals() method (DG);
|
||||
* 30-Nov-2005 : Removed get/setPlotArea() (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 01-Dec-2006 : Fixed equals() and clone() (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.entity.EntityCollection;
|
||||
import org.jfree.chart.entity.StandardEntityCollection;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* A structure for storing rendering information from one call to the
|
||||
* JFreeChart.draw() method.
|
||||
* <P>
|
||||
* An instance of the {@link JFreeChart} class can draw itself within an
|
||||
* arbitrary rectangle on any <code>Graphics2D</code>. It is assumed that
|
||||
* client code will sometimes render the same chart in more than one view, so
|
||||
* the {@link JFreeChart} instance does not retain any information about its
|
||||
* rendered dimensions. This information can be useful sometimes, so you have
|
||||
* the option to collect the information at each call to
|
||||
* <code>JFreeChart.draw()</code>, by passing an instance of this
|
||||
* <code>ChartRenderingInfo</code> class.
|
||||
*/
|
||||
public class ChartRenderingInfo implements Cloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = 2751952018173406822L;
|
||||
|
||||
/** The area in which the chart is drawn. */
|
||||
private transient Rectangle2D chartArea;
|
||||
|
||||
/** Rendering info for the chart's plot (and subplots, if any). */
|
||||
private PlotRenderingInfo plotInfo;
|
||||
|
||||
/**
|
||||
* Storage for the chart entities. Since retaining entity information for
|
||||
* charts with a large number of data points consumes a lot of memory, it
|
||||
* is intended that you can set this to <code>null</code> to prevent the
|
||||
* information being collected.
|
||||
*/
|
||||
private EntityCollection entities;
|
||||
|
||||
/**
|
||||
* Constructs a new ChartRenderingInfo structure that can be used to
|
||||
* collect information about the dimensions of a rendered chart.
|
||||
*/
|
||||
public ChartRenderingInfo() {
|
||||
this(new StandardEntityCollection());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance. If an entity collection is supplied, it will
|
||||
* be populated with information about the entities in a chart. If it is
|
||||
* <code>null</code>, no entity information (including tool tips) will
|
||||
* be collected.
|
||||
*
|
||||
* @param entities an entity collection (<code>null</code> permitted).
|
||||
*/
|
||||
public ChartRenderingInfo(EntityCollection entities) {
|
||||
this.chartArea = new Rectangle2D.Double();
|
||||
this.plotInfo = new PlotRenderingInfo(this);
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the area in which the chart was drawn.
|
||||
*
|
||||
* @return The area in which the chart was drawn.
|
||||
*
|
||||
* @see #setChartArea(Rectangle2D)
|
||||
*/
|
||||
public Rectangle2D getChartArea() {
|
||||
return this.chartArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the area in which the chart was drawn.
|
||||
*
|
||||
* @param area the chart area.
|
||||
*
|
||||
* @see #getChartArea()
|
||||
*/
|
||||
public void setChartArea(Rectangle2D area) {
|
||||
this.chartArea.setRect(area);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the collection of entities maintained by this instance.
|
||||
*
|
||||
* @return The entity collection (possibly <code>null</code>).
|
||||
*
|
||||
* @see #setEntityCollection(EntityCollection)
|
||||
*/
|
||||
public EntityCollection getEntityCollection() {
|
||||
return this.entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the entity collection.
|
||||
*
|
||||
* @param entities the entity collection (<code>null</code> permitted).
|
||||
*
|
||||
* @see #getEntityCollection()
|
||||
*/
|
||||
public void setEntityCollection(EntityCollection entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the information recorded by this object.
|
||||
*/
|
||||
public void clear() {
|
||||
this.chartArea.setRect(0.0, 0.0, 0.0, 0.0);
|
||||
this.plotInfo = new PlotRenderingInfo(this);
|
||||
if (this.entities != null) {
|
||||
this.entities.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rendering info for the chart's plot.
|
||||
*
|
||||
* @return The rendering info for the plot.
|
||||
*/
|
||||
public PlotRenderingInfo getPlotInfo() {
|
||||
return this.plotInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this object for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object to test against (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ChartRenderingInfo)) {
|
||||
return false;
|
||||
}
|
||||
ChartRenderingInfo that = (ChartRenderingInfo) obj;
|
||||
if (!ObjectUtilities.equal(this.chartArea, that.chartArea)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.plotInfo, that.plotInfo)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.entities, that.entities)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of this object.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if the object cannot be cloned.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
ChartRenderingInfo clone = (ChartRenderingInfo) super.clone();
|
||||
if (this.chartArea != null) {
|
||||
clone.chartArea = (Rectangle2D) this.chartArea.clone();
|
||||
}
|
||||
if (this.entities instanceof PublicCloneable) {
|
||||
PublicCloneable pc = (PublicCloneable) this.entities;
|
||||
clone.entities = (EntityCollection) pc.clone();
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
SerialUtilities.writeShape(this.chartArea, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.chartArea = (Rectangle2D) SerialUtilities.readShape(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------
|
||||
* ChartTheme.java
|
||||
* ---------------
|
||||
* (C) Copyright 2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 14-Aug-2008 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import org.jfree.chart.JFreeChart;
|
||||
|
||||
/**
|
||||
* A {@link ChartTheme} a class that can apply a style or 'theme' to a chart.
|
||||
* It can be implemented in an arbitrary manner, with the styling applied to
|
||||
* the chart via the <code>apply(JFreeChart)</code> method. We provide one
|
||||
* implementation ({@link StandardChartTheme}) that just mimics the manual
|
||||
* process of calling methods to set various chart parameters.
|
||||
*
|
||||
* @since 1.0.11
|
||||
*/
|
||||
public interface ChartTheme {
|
||||
|
||||
/**
|
||||
* Applies this theme to the supplied chart.
|
||||
*
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
*/
|
||||
public void apply(JFreeChart chart);
|
||||
|
||||
}
|
||||
@@ -1,762 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------
|
||||
* ChartUtilities.java
|
||||
* -------------------
|
||||
* (C) Copyright 2001-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Wolfgang Irler;
|
||||
* Richard Atkinson;
|
||||
* Xavier Poinsard;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 11-Dec-2001 : Version 1. The JPEG method comes from Wolfgang Irler's
|
||||
* JFreeChartServletDemo class (DG);
|
||||
* 23-Jan-2002 : Changed saveChartAsXXX() methods to pass IOExceptions back to
|
||||
* caller (DG);
|
||||
* 26-Jun-2002 : Added image map methods (DG);
|
||||
* 05-Aug-2002 : Added writeBufferedImage methods
|
||||
* Modified writeImageMap method to support flexible image
|
||||
* maps (RA);
|
||||
* 26-Aug-2002 : Added saveChartAsJPEG and writeChartAsJPEG methods with info
|
||||
* objects (RA);
|
||||
* 05-Sep-2002 : Added writeImageMap() method to support OverLIB
|
||||
* - http://www.bosrup.com/web/overlib (RA);
|
||||
* 26-Sep-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 17-Oct-2002 : Exposed JPEG quality setting and PNG compression level as
|
||||
* parameters (DG);
|
||||
* 25-Oct-2002 : Fixed writeChartAsJPEG() empty method bug (DG);
|
||||
* 13-Mar-2003 : Updated writeImageMap method as suggested by Xavier Poinsard
|
||||
* (see Feature Request 688079) (DG);
|
||||
* 12-Aug-2003 : Added support for custom image maps using
|
||||
* ToolTipTagFragmentGenerator and URLTagFragmentGenerator (RA);
|
||||
* 02-Sep-2003 : Separated PNG encoding from writing chart to an
|
||||
* OutputStream (RA);
|
||||
* 04-Dec-2003 : Chart draw() method modified to include anchor point (DG);
|
||||
* 20-Feb-2004 : Edited Javadocs and added argument checking (DG);
|
||||
* 05-Apr-2004 : Fixed problem with buffered image type (DG);
|
||||
* 01-Aug-2004 : Modified to use EncoderUtil for all image encoding (RA);
|
||||
* 02-Aug-2004 : Delegated image map related functionality to ImageMapUtil (RA);
|
||||
* 13-Jan-2005 : Renamed ImageMapUtil --> ImageMapUtilities, removed method
|
||||
* writeImageMap(PrintWriter, String, ChartRenderingInfo) which
|
||||
* exists in ImageMapUtilities (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 06-Feb-2006 : API doc update (DG);
|
||||
* 19-Mar-2007 : Use try-finally to close output stream in saveChartAsXXX()
|
||||
* methods (DG);
|
||||
* 10-Jan-2008 : Fix bug 1868251 - don't create image with transparency when
|
||||
* saving to JPEG format (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.jfree.chart.encoders.EncoderUtil;
|
||||
import org.jfree.chart.encoders.ImageFormat;
|
||||
import org.jfree.chart.imagemap.ImageMapUtilities;
|
||||
import org.jfree.chart.imagemap.OverLIBToolTipTagFragmentGenerator;
|
||||
import org.jfree.chart.imagemap.StandardToolTipTagFragmentGenerator;
|
||||
import org.jfree.chart.imagemap.StandardURLTagFragmentGenerator;
|
||||
import org.jfree.chart.imagemap.ToolTipTagFragmentGenerator;
|
||||
import org.jfree.chart.imagemap.URLTagFragmentGenerator;
|
||||
|
||||
/**
|
||||
* A collection of utility methods for JFreeChart. Includes methods for
|
||||
* converting charts to image formats (PNG and JPEG) plus creating simple HTML
|
||||
* image maps.
|
||||
*
|
||||
* @see ImageMapUtilities
|
||||
*/
|
||||
public abstract class ChartUtilities {
|
||||
|
||||
/**
|
||||
* Applies the current theme to the specified chart. This method is
|
||||
* provided for convenience, the theme itself is stored in the
|
||||
* {@link ChartFactory} class.
|
||||
*
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
*
|
||||
* @since 1.0.11
|
||||
*/
|
||||
public static void applyCurrentTheme(JFreeChart chart) {
|
||||
ChartFactory.getChartTheme().apply(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in PNG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
|
||||
int width, int height) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
writeChartAsPNG(out, chart, width, height, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in PNG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param encodeAlpha encode alpha?
|
||||
* @param compression the compression level (0-9).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
|
||||
int width, int height, boolean encodeAlpha, int compression)
|
||||
throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
ChartUtilities.writeChartAsPNG(out, chart, width, height, null,
|
||||
encodeAlpha, compression);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in PNG format. This method allows
|
||||
* you to pass in a {@link ChartRenderingInfo} object, to collect
|
||||
* information about the chart dimensions/entities. You will need this
|
||||
* info if you want to create an HTML image map.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
|
||||
int width, int height, ChartRenderingInfo info)
|
||||
throws IOException {
|
||||
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
BufferedImage bufferedImage
|
||||
= chart.createBufferedImage(width, height, info);
|
||||
EncoderUtil.writeBufferedImage(bufferedImage, ImageFormat.PNG, out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in PNG format. This method allows
|
||||
* you to pass in a {@link ChartRenderingInfo} object, to collect
|
||||
* information about the chart dimensions/entities. You will need this
|
||||
* info if you want to create an HTML image map.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info carries back chart rendering info (<code>null</code>
|
||||
* permitted).
|
||||
* @param encodeAlpha encode alpha?
|
||||
* @param compression the PNG compression level (0-9).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
|
||||
int width, int height, ChartRenderingInfo info,
|
||||
boolean encodeAlpha, int compression) throws IOException {
|
||||
|
||||
if (out == null) {
|
||||
throw new IllegalArgumentException("Null 'out' argument.");
|
||||
}
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
BufferedImage chartImage = chart.createBufferedImage(width, height,
|
||||
BufferedImage.TYPE_INT_ARGB, info);
|
||||
ChartUtilities.writeBufferedImageAsPNG(out, chartImage, encodeAlpha,
|
||||
compression);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a scaled version of a chart to an output stream in PNG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the unscaled chart width.
|
||||
* @param height the unscaled chart height.
|
||||
* @param widthScaleFactor the horizontal scale factor.
|
||||
* @param heightScaleFactor the vertical scale factor.
|
||||
*
|
||||
* @throws IOException if there are any I/O problems.
|
||||
*/
|
||||
public static void writeScaledChartAsPNG(OutputStream out,
|
||||
JFreeChart chart, int width, int height, int widthScaleFactor,
|
||||
int heightScaleFactor) throws IOException {
|
||||
|
||||
if (out == null) {
|
||||
throw new IllegalArgumentException("Null 'out' argument.");
|
||||
}
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
|
||||
double desiredWidth = width * widthScaleFactor;
|
||||
double desiredHeight = height * heightScaleFactor;
|
||||
double defaultWidth = width;
|
||||
double defaultHeight = height;
|
||||
boolean scale = false;
|
||||
|
||||
// get desired width and height from somewhere then...
|
||||
if ((widthScaleFactor != 1) || (heightScaleFactor != 1)) {
|
||||
scale = true;
|
||||
}
|
||||
|
||||
double scaleX = desiredWidth / defaultWidth;
|
||||
double scaleY = desiredHeight / defaultHeight;
|
||||
|
||||
BufferedImage image = new BufferedImage((int) desiredWidth,
|
||||
(int) desiredHeight, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2 = image.createGraphics();
|
||||
|
||||
if (scale) {
|
||||
AffineTransform saved = g2.getTransform();
|
||||
g2.transform(AffineTransform.getScaleInstance(scaleX, scaleY));
|
||||
chart.draw(g2, new Rectangle2D.Double(0, 0, defaultWidth,
|
||||
defaultHeight), null, null);
|
||||
g2.setTransform(saved);
|
||||
g2.dispose();
|
||||
}
|
||||
else {
|
||||
chart.draw(g2, new Rectangle2D.Double(0, 0, defaultWidth,
|
||||
defaultHeight), null, null);
|
||||
}
|
||||
out.write(encodeAsPNG(image));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to the specified file in PNG format.
|
||||
*
|
||||
* @param file the file name (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsPNG(File file, JFreeChart chart,
|
||||
int width, int height) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
saveChartAsPNG(file, chart, width, height, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to a file in PNG format. This method allows you to pass
|
||||
* in a {@link ChartRenderingInfo} object, to collect information about the
|
||||
* chart dimensions/entities. You will need this info if you want to
|
||||
* create an HTML image map.
|
||||
*
|
||||
* @param file the file (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsPNG(File file, JFreeChart chart,
|
||||
int width, int height, ChartRenderingInfo info)
|
||||
throws IOException {
|
||||
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("Null 'file' argument.");
|
||||
}
|
||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
|
||||
try {
|
||||
ChartUtilities.writeChartAsPNG(out, chart, width, height, info);
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to a file in PNG format. This method allows you to pass
|
||||
* in a {@link ChartRenderingInfo} object, to collect information about the
|
||||
* chart dimensions/entities. You will need this info if you want to
|
||||
* create an HTML image map.
|
||||
*
|
||||
* @param file the file (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
* @param encodeAlpha encode alpha?
|
||||
* @param compression the PNG compression level (0-9).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsPNG(File file, JFreeChart chart,
|
||||
int width, int height, ChartRenderingInfo info, boolean encodeAlpha,
|
||||
int compression) throws IOException {
|
||||
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("Null 'file' argument.");
|
||||
}
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
|
||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
|
||||
try {
|
||||
writeChartAsPNG(out, chart, width, height, info, encodeAlpha,
|
||||
compression);
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in JPEG format. Please note that
|
||||
* JPEG is a poor format for chart images, use PNG if possible.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsJPEG(OutputStream out,
|
||||
JFreeChart chart, int width, int height) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
writeChartAsJPEG(out, chart, width, height, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in JPEG format. Please note that
|
||||
* JPEG is a poor format for chart images, use PNG if possible.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param quality the quality setting.
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsJPEG(OutputStream out, float quality,
|
||||
JFreeChart chart, int width, int height) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
ChartUtilities.writeChartAsJPEG(out, quality, chart, width, height,
|
||||
null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in JPEG format. This method allows
|
||||
* you to pass in a {@link ChartRenderingInfo} object, to collect
|
||||
* information about the chart dimensions/entities. You will need this
|
||||
* info if you want to create an HTML image map.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsJPEG(OutputStream out, JFreeChart chart,
|
||||
int width, int height, ChartRenderingInfo info)
|
||||
throws IOException {
|
||||
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
BufferedImage image = chart.createBufferedImage(width, height,
|
||||
BufferedImage.TYPE_INT_RGB, info);
|
||||
EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in JPEG format. This method allows
|
||||
* you to pass in a {@link ChartRenderingInfo} object, to collect
|
||||
* information about the chart dimensions/entities. You will need this
|
||||
* info if you want to create an HTML image map.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param quality the output quality (0.0f to 1.0f).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsJPEG(OutputStream out, float quality,
|
||||
JFreeChart chart, int width, int height, ChartRenderingInfo info)
|
||||
throws IOException {
|
||||
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
BufferedImage image = chart.createBufferedImage(width, height,
|
||||
BufferedImage.TYPE_INT_RGB, info);
|
||||
EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to a file in JPEG format.
|
||||
*
|
||||
* @param file the file (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsJPEG(File file, JFreeChart chart,
|
||||
int width, int height) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
saveChartAsJPEG(file, chart, width, height, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to a file in JPEG format.
|
||||
*
|
||||
* @param file the file (<code>null</code> not permitted).
|
||||
* @param quality the JPEG quality setting.
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsJPEG(File file, float quality,
|
||||
JFreeChart chart, int width, int height) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
saveChartAsJPEG(file, quality, chart, width, height, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to a file in JPEG format. This method allows you to pass
|
||||
* in a {@link ChartRenderingInfo} object, to collect information about the
|
||||
* chart dimensions/entities. You will need this info if you want to
|
||||
* create an HTML image map.
|
||||
*
|
||||
* @param file the file name (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsJPEG(File file, JFreeChart chart,
|
||||
int width, int height, ChartRenderingInfo info) throws IOException {
|
||||
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("Null 'file' argument.");
|
||||
}
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
|
||||
try {
|
||||
writeChartAsJPEG(out, chart, width, height, info);
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to a file in JPEG format. This method allows you to pass
|
||||
* in a {@link ChartRenderingInfo} object, to collect information about the
|
||||
* chart dimensions/entities. You will need this info if you want to
|
||||
* create an HTML image map.
|
||||
*
|
||||
* @param file the file name (<code>null</code> not permitted).
|
||||
* @param quality the quality setting.
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsJPEG(File file, float quality,
|
||||
JFreeChart chart, int width, int height,
|
||||
ChartRenderingInfo info) throws IOException {
|
||||
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("Null 'file' argument.");
|
||||
}
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
|
||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(
|
||||
file));
|
||||
try {
|
||||
writeChartAsJPEG(out, quality, chart, width, height, info);
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link BufferedImage} to an output stream in JPEG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeBufferedImageAsJPEG(OutputStream out,
|
||||
BufferedImage image) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
writeBufferedImageAsJPEG(out, 0.75f, image);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link BufferedImage} to an output stream in JPEG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param quality the image quality (0.0f to 1.0f).
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeBufferedImageAsJPEG(OutputStream out, float quality,
|
||||
BufferedImage image) throws IOException {
|
||||
|
||||
EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link BufferedImage} to an output stream in PNG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeBufferedImageAsPNG(OutputStream out,
|
||||
BufferedImage image) throws IOException {
|
||||
|
||||
EncoderUtil.writeBufferedImage(image, ImageFormat.PNG, out);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link BufferedImage} to an output stream in PNG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
* @param encodeAlpha encode alpha?
|
||||
* @param compression the compression level (0-9).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeBufferedImageAsPNG(OutputStream out,
|
||||
BufferedImage image, boolean encodeAlpha, int compression)
|
||||
throws IOException {
|
||||
|
||||
EncoderUtil.writeBufferedImage(image, ImageFormat.PNG, out,
|
||||
compression, encodeAlpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a {@link BufferedImage} to PNG format.
|
||||
*
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
*
|
||||
* @return A byte array in PNG format.
|
||||
*
|
||||
* @throws IOException if there is an I/O problem.
|
||||
*/
|
||||
public static byte[] encodeAsPNG(BufferedImage image) throws IOException {
|
||||
return EncoderUtil.encode(image, ImageFormat.PNG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a {@link BufferedImage} to PNG format.
|
||||
*
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
* @param encodeAlpha encode alpha?
|
||||
* @param compression the PNG compression level (0-9).
|
||||
*
|
||||
* @return The byte array in PNG format.
|
||||
*
|
||||
* @throws IOException if there is an I/O problem.
|
||||
*/
|
||||
public static byte[] encodeAsPNG(BufferedImage image, boolean encodeAlpha,
|
||||
int compression)
|
||||
throws IOException {
|
||||
return EncoderUtil.encode(image, ImageFormat.PNG, compression,
|
||||
encodeAlpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an image map to an output stream.
|
||||
*
|
||||
* @param writer the writer (<code>null</code> not permitted).
|
||||
* @param name the map name (<code>null</code> not permitted).
|
||||
* @param info the chart rendering info (<code>null</code> not permitted).
|
||||
* @param useOverLibForToolTips whether to use OverLIB for tooltips
|
||||
* (http://www.bosrup.com/web/overlib/).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeImageMap(PrintWriter writer,
|
||||
String name,
|
||||
ChartRenderingInfo info,
|
||||
boolean useOverLibForToolTips)
|
||||
throws IOException {
|
||||
|
||||
ToolTipTagFragmentGenerator toolTipTagFragmentGenerator = null;
|
||||
if (useOverLibForToolTips) {
|
||||
toolTipTagFragmentGenerator
|
||||
= new OverLIBToolTipTagFragmentGenerator();
|
||||
}
|
||||
else {
|
||||
toolTipTagFragmentGenerator
|
||||
= new StandardToolTipTagFragmentGenerator();
|
||||
}
|
||||
ImageMapUtilities.writeImageMap(writer, name, info,
|
||||
toolTipTagFragmentGenerator,
|
||||
new StandardURLTagFragmentGenerator());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an image map to the specified writer.
|
||||
*
|
||||
* @param writer the writer (<code>null</code> not permitted).
|
||||
* @param name the map name (<code>null</code> not permitted).
|
||||
* @param info the chart rendering info (<code>null</code> not permitted).
|
||||
* @param toolTipTagFragmentGenerator a generator for the HTML fragment
|
||||
* that will contain the tooltip text (<code>null</code> not permitted
|
||||
* if <code>info</code> contains tooltip information).
|
||||
* @param urlTagFragmentGenerator a generator for the HTML fragment that
|
||||
* will contain the URL reference (<code>null</code> not permitted if
|
||||
* <code>info</code> contains URLs).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeImageMap(PrintWriter writer, String name,
|
||||
ChartRenderingInfo info,
|
||||
ToolTipTagFragmentGenerator toolTipTagFragmentGenerator,
|
||||
URLTagFragmentGenerator urlTagFragmentGenerator)
|
||||
throws IOException {
|
||||
|
||||
writer.println(ImageMapUtilities.getImageMap(name, info,
|
||||
toolTipTagFragmentGenerator, urlTagFragmentGenerator));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML image map. This method maps to
|
||||
* {@link ImageMapUtilities#getImageMap(String, ChartRenderingInfo,
|
||||
* ToolTipTagFragmentGenerator, URLTagFragmentGenerator)}, using default
|
||||
* generators.
|
||||
*
|
||||
* @param name the map name (<code>null</code> not permitted).
|
||||
* @param info the chart rendering info (<code>null</code> not permitted).
|
||||
*
|
||||
* @return The map tag.
|
||||
*/
|
||||
public static String getImageMap(String name, ChartRenderingInfo info) {
|
||||
return ImageMapUtilities.getImageMap(name, info,
|
||||
new StandardToolTipTagFragmentGenerator(),
|
||||
new StandardURLTagFragmentGenerator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML image map. This method maps directly to
|
||||
* {@link ImageMapUtilities#getImageMap(String, ChartRenderingInfo,
|
||||
* ToolTipTagFragmentGenerator, URLTagFragmentGenerator)}.
|
||||
*
|
||||
* @param name the map name (<code>null</code> not permitted).
|
||||
* @param info the chart rendering info (<code>null</code> not permitted).
|
||||
* @param toolTipTagFragmentGenerator a generator for the HTML fragment
|
||||
* that will contain the tooltip text (<code>null</code> not permitted
|
||||
* if <code>info</code> contains tooltip information).
|
||||
* @param urlTagFragmentGenerator a generator for the HTML fragment that
|
||||
* will contain the URL reference (<code>null</code> not permitted if
|
||||
* <code>info</code> contains URLs).
|
||||
*
|
||||
* @return The map tag.
|
||||
*/
|
||||
public static String getImageMap(String name, ChartRenderingInfo info,
|
||||
ToolTipTagFragmentGenerator toolTipTagFragmentGenerator,
|
||||
URLTagFragmentGenerator urlTagFragmentGenerator) {
|
||||
|
||||
return ImageMapUtilities.getImageMap(name, info,
|
||||
toolTipTagFragmentGenerator, urlTagFragmentGenerator);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,439 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------
|
||||
* ClipPath.java
|
||||
* -------------
|
||||
* (C) Copyright 2003-2008, by David M. O'Donnell and Contributors.
|
||||
*
|
||||
* Original Author: David M. O'Donnell;
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
* Nicolas Brodu;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 22-Apr-2003 : Added standard header (DG);
|
||||
* 09-May-2003 : Added AxisLocation (DG);
|
||||
* 11-Sep-2003 : Implemented Cloneable (NB);
|
||||
* 21-Jan-2004 : Update for renamed method in ValueAxis (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 31-Jan-2007 : Deprecated (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.chart.renderer.xy.XYBlockRenderer;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
|
||||
/**
|
||||
* This class would typically be used with a
|
||||
* {@link org.jfree.chart.plot.ContourPlot}. It allows the user to define a
|
||||
* <code>GeneralPath</code> curve in plot coordinates. This curve can then be
|
||||
* used mask off or define regions within the contour plot. The data must be
|
||||
* sorted.
|
||||
*
|
||||
* @deprecated This class is no longer supported (as of version 1.0.4). If
|
||||
* you are creating contour plots, please try to use {@link XYPlot} and
|
||||
* {@link XYBlockRenderer}.
|
||||
*/
|
||||
public class ClipPath implements Cloneable {
|
||||
|
||||
/** The x values. */
|
||||
private double[] xValue = null;
|
||||
|
||||
/** The y values. */
|
||||
private double[] yValue = null;
|
||||
|
||||
/** Controls whether drawing will be clipped (
|
||||
* false would still allow the drawing or filling of path */
|
||||
private boolean clip = true;
|
||||
|
||||
/** Controls whether the path is drawn as an outline. */
|
||||
private boolean drawPath = false;
|
||||
|
||||
/** Controls whether the path is filled. */
|
||||
private boolean fillPath = false;
|
||||
|
||||
/** The fill paint. */
|
||||
private Paint fillPaint = null;
|
||||
|
||||
/** The draw paint. */
|
||||
private Paint drawPaint = null;
|
||||
|
||||
/** The draw stroke. */
|
||||
private Stroke drawStroke = null;
|
||||
|
||||
/** The composite. */
|
||||
private Composite composite = null;
|
||||
|
||||
/**
|
||||
* Constructor for ClipPath.
|
||||
*/
|
||||
public ClipPath() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for ClipPath.
|
||||
* Default values are assumed for the fillPath and drawPath options as
|
||||
* false and true respectively. The fillPaint is set to Color.GRAY, the
|
||||
* drawColor is Color.BLUE, the stroke is BasicStroke(1)
|
||||
* and the composite is AlphaComposite.Src.
|
||||
*
|
||||
* @param xValue x coordinates of curved to be created
|
||||
* @param yValue y coordinates of curved to be created
|
||||
*/
|
||||
public ClipPath(double[] xValue, double[] yValue) {
|
||||
this(xValue, yValue, true, false, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for ClipPath.
|
||||
* The fillPaint is set to Color.GRAY, the drawColor is Color.BLUE, the
|
||||
* stroke is BasicStroke(1) and the composite is AlphaComposite.Src.
|
||||
*
|
||||
* @param xValue x coordinates of curved to be created
|
||||
* @param yValue y coordinates of curved to be created
|
||||
* @param clip clip?
|
||||
* @param fillPath whether the path is to filled
|
||||
* @param drawPath whether the path is to drawn as an outline
|
||||
*/
|
||||
public ClipPath(double[] xValue, double[] yValue,
|
||||
boolean clip, boolean fillPath, boolean drawPath) {
|
||||
this.xValue = xValue;
|
||||
this.yValue = yValue;
|
||||
|
||||
this.clip = clip;
|
||||
this.fillPath = fillPath;
|
||||
this.drawPath = drawPath;
|
||||
|
||||
this.fillPaint = java.awt.Color.gray;
|
||||
this.drawPaint = java.awt.Color.blue;
|
||||
this.drawStroke = new BasicStroke(1);
|
||||
this.composite = java.awt.AlphaComposite.Src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for ClipPath.
|
||||
*
|
||||
* @param xValue x coordinates of curved to be created
|
||||
* @param yValue y coordinates of curved to be created
|
||||
* @param fillPath whether the path is to filled
|
||||
* @param drawPath whether the path is to drawn as an outline
|
||||
* @param fillPaint the fill paint
|
||||
* @param drawPaint the outline stroke color
|
||||
* @param drawStroke the stroke style
|
||||
* @param composite the composite rule
|
||||
*/
|
||||
public ClipPath(double[] xValue, double[] yValue, boolean fillPath,
|
||||
boolean drawPath, Paint fillPaint, Paint drawPaint,
|
||||
Stroke drawStroke, Composite composite) {
|
||||
|
||||
this.xValue = xValue;
|
||||
this.yValue = yValue;
|
||||
|
||||
this.fillPath = fillPath;
|
||||
this.drawPath = drawPath;
|
||||
|
||||
this.fillPaint = fillPaint;
|
||||
this.drawPaint = drawPaint;
|
||||
this.drawStroke = drawStroke;
|
||||
this.composite = composite;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the clip path.
|
||||
*
|
||||
* @param g2 current graphics2D.
|
||||
* @param dataArea the dataArea that the plot is being draw in.
|
||||
* @param horizontalAxis the horizontal axis.
|
||||
* @param verticalAxis the vertical axis.
|
||||
*
|
||||
* @return The GeneralPath defining the outline
|
||||
*/
|
||||
public GeneralPath draw(Graphics2D g2,
|
||||
Rectangle2D dataArea,
|
||||
ValueAxis horizontalAxis, ValueAxis verticalAxis) {
|
||||
|
||||
GeneralPath generalPath = generateClipPath(
|
||||
dataArea, horizontalAxis, verticalAxis
|
||||
);
|
||||
if (this.fillPath || this.drawPath) {
|
||||
Composite saveComposite = g2.getComposite();
|
||||
Paint savePaint = g2.getPaint();
|
||||
Stroke saveStroke = g2.getStroke();
|
||||
|
||||
if (this.fillPaint != null) {
|
||||
g2.setPaint(this.fillPaint);
|
||||
}
|
||||
if (this.composite != null) {
|
||||
g2.setComposite(this.composite);
|
||||
}
|
||||
if (this.fillPath) {
|
||||
g2.fill(generalPath);
|
||||
}
|
||||
|
||||
if (this.drawStroke != null) {
|
||||
g2.setStroke(this.drawStroke);
|
||||
}
|
||||
if (this.drawPath) {
|
||||
g2.draw(generalPath);
|
||||
}
|
||||
g2.setPaint(savePaint);
|
||||
g2.setComposite(saveComposite);
|
||||
g2.setStroke(saveStroke);
|
||||
}
|
||||
return generalPath;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the clip path.
|
||||
*
|
||||
* @param dataArea the dataArea that the plot is being draw in.
|
||||
* @param horizontalAxis the horizontal axis.
|
||||
* @param verticalAxis the vertical axis.
|
||||
*
|
||||
* @return The GeneralPath defining the outline
|
||||
*/
|
||||
public GeneralPath generateClipPath(Rectangle2D dataArea,
|
||||
ValueAxis horizontalAxis,
|
||||
ValueAxis verticalAxis) {
|
||||
|
||||
GeneralPath generalPath = new GeneralPath();
|
||||
double transX = horizontalAxis.valueToJava2D(
|
||||
this.xValue[0], dataArea, RectangleEdge.BOTTOM
|
||||
);
|
||||
double transY = verticalAxis.valueToJava2D(
|
||||
this.yValue[0], dataArea, RectangleEdge.LEFT
|
||||
);
|
||||
generalPath.moveTo((float) transX, (float) transY);
|
||||
for (int k = 0; k < this.yValue.length; k++) {
|
||||
transX = horizontalAxis.valueToJava2D(
|
||||
this.xValue[k], dataArea, RectangleEdge.BOTTOM
|
||||
);
|
||||
transY = verticalAxis.valueToJava2D(
|
||||
this.yValue[k], dataArea, RectangleEdge.LEFT
|
||||
);
|
||||
generalPath.lineTo((float) transX, (float) transY);
|
||||
}
|
||||
generalPath.closePath();
|
||||
|
||||
return generalPath;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the composite.
|
||||
*
|
||||
* @return Composite
|
||||
*/
|
||||
public Composite getComposite() {
|
||||
return this.composite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the drawPaint.
|
||||
*
|
||||
* @return Paint
|
||||
*/
|
||||
public Paint getDrawPaint() {
|
||||
return this.drawPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the drawPath.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isDrawPath() {
|
||||
return this.drawPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the drawStroke.
|
||||
*
|
||||
* @return Stroke
|
||||
*/
|
||||
public Stroke getDrawStroke() {
|
||||
return this.drawStroke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fillPaint.
|
||||
*
|
||||
* @return Paint
|
||||
*/
|
||||
public Paint getFillPaint() {
|
||||
return this.fillPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fillPath.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isFillPath() {
|
||||
return this.fillPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the xValue.
|
||||
*
|
||||
* @return double[]
|
||||
*/
|
||||
public double[] getXValue() {
|
||||
return this.xValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the yValue.
|
||||
*
|
||||
* @return double[]
|
||||
*/
|
||||
public double[] getYValue() {
|
||||
return this.yValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the composite.
|
||||
*
|
||||
* @param composite The composite to set
|
||||
*/
|
||||
public void setComposite(Composite composite) {
|
||||
this.composite = composite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the drawPaint.
|
||||
*
|
||||
* @param drawPaint The drawPaint to set
|
||||
*/
|
||||
public void setDrawPaint(Paint drawPaint) {
|
||||
this.drawPaint = drawPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the drawPath.
|
||||
*
|
||||
* @param drawPath The drawPath to set
|
||||
*/
|
||||
public void setDrawPath(boolean drawPath) {
|
||||
this.drawPath = drawPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the drawStroke.
|
||||
*
|
||||
* @param drawStroke The drawStroke to set
|
||||
*/
|
||||
public void setDrawStroke(Stroke drawStroke) {
|
||||
this.drawStroke = drawStroke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fillPaint.
|
||||
*
|
||||
* @param fillPaint The fillPaint to set
|
||||
*/
|
||||
public void setFillPaint(Paint fillPaint) {
|
||||
this.fillPaint = fillPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fillPath.
|
||||
*
|
||||
* @param fillPath The fillPath to set
|
||||
*/
|
||||
public void setFillPath(boolean fillPath) {
|
||||
this.fillPath = fillPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the xValue.
|
||||
*
|
||||
* @param xValue The xValue to set
|
||||
*/
|
||||
public void setXValue(double[] xValue) {
|
||||
this.xValue = xValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the yValue.
|
||||
*
|
||||
* @param yValue The yValue to set
|
||||
*/
|
||||
public void setYValue(double[] yValue) {
|
||||
this.yValue = yValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the clip.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isClip() {
|
||||
return this.clip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the clip.
|
||||
*
|
||||
* @param clip The clip to set
|
||||
*/
|
||||
public void setClip(boolean clip) {
|
||||
this.clip = clip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the object (a deeper clone than default to avoid bugs
|
||||
* when setting values in cloned object).
|
||||
*
|
||||
* @return The clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if cloning is not supported.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
ClipPath clone = (ClipPath) super.clone();
|
||||
clone.xValue = (double[]) this.xValue.clone();
|
||||
clone.yValue = (double[]) this.yValue.clone();
|
||||
return clone;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -----------------------
|
||||
* DrawableLegendItem.java
|
||||
* -----------------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Luke Quinane;
|
||||
* Barak Naveh;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 07-Feb-2002 : Version 1 (DG);
|
||||
* 23-Sep-2002 : Renamed LegendItem --> DrawableLegendItem (DG);
|
||||
* 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 08-Oct-2003 : Applied patch for displaying series line style, contributed by
|
||||
* Luke Quinane (DG);
|
||||
* 27-Mar-2004 : Added getMaxX() and getMaxY() methods (BN);
|
||||
* 27-Jan-2005 : Cleared out code that belongs in the LegendItem class (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
/**
|
||||
* This class contains a single legend item along with position details for
|
||||
* drawing the item on a particular chart.
|
||||
*
|
||||
* @deprecated This class is not used by JFreeChart.
|
||||
*/
|
||||
public class DrawableLegendItem {
|
||||
|
||||
/**
|
||||
* The legend item (encapsulates information about the label, color and
|
||||
* shape).
|
||||
*/
|
||||
private LegendItem item;
|
||||
|
||||
/** The x-coordinate for the item's location. */
|
||||
private double x;
|
||||
|
||||
/** The y-coordinate for the item's location. */
|
||||
private double y;
|
||||
|
||||
/** The width of the item. */
|
||||
private double width;
|
||||
|
||||
/** The height of the item. */
|
||||
private double height;
|
||||
|
||||
/** A shape used to indicate color on the legend. */
|
||||
private Shape marker;
|
||||
|
||||
/** A line used to indicate the series stroke on the legend */
|
||||
private Line2D line;
|
||||
|
||||
/** The label position within the item. */
|
||||
private Point2D labelPosition;
|
||||
|
||||
/**
|
||||
* Create a legend item.
|
||||
*
|
||||
* @param item the legend item for display.
|
||||
*/
|
||||
public DrawableLegendItem(LegendItem item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the legend item.
|
||||
*
|
||||
* @return The legend item.
|
||||
*/
|
||||
public LegendItem getItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the x-coordinate for the item's location.
|
||||
*
|
||||
* @return The x-coordinate for the item's location.
|
||||
*/
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the x-coordinate for the item's location.
|
||||
*
|
||||
* @param x the x-coordinate.
|
||||
*/
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the y-coordinate for the item's location.
|
||||
*
|
||||
* @return The y-coordinate for the item's location.
|
||||
*/
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the y-coordinate for the item's location.
|
||||
*
|
||||
* @param y the y-coordinate.
|
||||
*/
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of this item.
|
||||
*
|
||||
* @return The width.
|
||||
*/
|
||||
public double getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of this item.
|
||||
*
|
||||
* @return The height.
|
||||
*/
|
||||
public double getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the largest X coordinate of the framing rectangle of this legend
|
||||
* item.
|
||||
*
|
||||
* @return The largest x coordinate of the framing rectangle of this legend
|
||||
* item.
|
||||
*/
|
||||
public double getMaxX() {
|
||||
return getX() + getWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the largest Y coordinate of the framing rectangle of this legend
|
||||
* item.
|
||||
*
|
||||
* @return The largest Y coordinate of the framing rectangle of this legend
|
||||
* item.
|
||||
*/
|
||||
public double getMaxY() {
|
||||
return getY() + getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the marker.
|
||||
*
|
||||
* @return The shape used to indicate color on the legend for this item.
|
||||
*/
|
||||
public Shape getMarker() {
|
||||
return this.marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the marker.
|
||||
*
|
||||
* @param marker a shape used to indicate color on the legend for this
|
||||
* item.
|
||||
*/
|
||||
public void setMarker(Shape marker) {
|
||||
this.marker = marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the line used to label this series.
|
||||
*
|
||||
* @param l the new line to use.
|
||||
*/
|
||||
public void setLine(Line2D l) {
|
||||
this.line = l;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list.
|
||||
*
|
||||
* @return The line.
|
||||
*/
|
||||
public Line2D getLine() {
|
||||
return this.line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label position.
|
||||
*
|
||||
* @return The label position.
|
||||
*/
|
||||
public Point2D getLabelPosition() {
|
||||
return this.labelPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label position.
|
||||
*
|
||||
* @param position the label position.
|
||||
*/
|
||||
public void setLabelPosition(Point2D position) {
|
||||
this.labelPosition = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bounds of this item.
|
||||
*
|
||||
* @param x x-coordinate for the item's location.
|
||||
* @param y y-coordinate for the item's location.
|
||||
* @param width the width of this item.
|
||||
* @param height the height of this item.
|
||||
*/
|
||||
public void setBounds(double x, double y, double width, double height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------
|
||||
* Effect3D.java
|
||||
* -------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 05-Nov-2002 : Version 1 (DG);
|
||||
* 14-Nov-2002 : Modified to have independent x and y offsets (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
/**
|
||||
* An interface that should be implemented by renderers that use a 3D effect.
|
||||
* This allows the axes to mirror the same effect by querying the renderer.
|
||||
*/
|
||||
public interface Effect3D {
|
||||
|
||||
/**
|
||||
* Returns the x-offset (in Java2D units) for the 3D effect.
|
||||
*
|
||||
* @return The offset.
|
||||
*/
|
||||
public double getXOffset();
|
||||
|
||||
/**
|
||||
* Returns the y-offset (in Java2D units) for the 3D effect.
|
||||
*
|
||||
* @return The offset.
|
||||
*/
|
||||
public double getYOffset();
|
||||
}
|
||||
@@ -1,347 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ------------------
|
||||
* HashUtilities.java
|
||||
* ------------------
|
||||
* (C) Copyright 2006, 2007, by Object Refinery Limited;
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 03-Oct-2006 : Version 1 (DG);
|
||||
* 06-Mar-2007 : Fix for hashCodeForDoubleArray() method (DG);
|
||||
* 13-Nov-2007 : Added new utility methods (DG);
|
||||
* 22-Nov-2007 : Added hashCode() method for 'int' (DG);
|
||||
* 05-Dec-2007 : Added special methods to handle BooleanList, PaintList,
|
||||
* and StrokeList (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Stroke;
|
||||
|
||||
import org.jfree.util.BooleanList;
|
||||
import org.jfree.util.PaintList;
|
||||
import org.jfree.util.StrokeList;
|
||||
|
||||
/**
|
||||
* Some utility methods for calculating hash codes.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*/
|
||||
public class HashUtilities {
|
||||
|
||||
/**
|
||||
* Returns a hash code for a <code>Paint</code> instance. If
|
||||
* <code>p</code> is <code>null</code>, this method returns zero.
|
||||
*
|
||||
* @param p the paint (<code>null</code> permitted).
|
||||
*
|
||||
* @return The hash code.
|
||||
*/
|
||||
public static int hashCodeForPaint(Paint p) {
|
||||
if (p == null) {
|
||||
return 0;
|
||||
}
|
||||
int result = 0;
|
||||
// handle GradientPaint as a special case
|
||||
if (p instanceof GradientPaint) {
|
||||
GradientPaint gp = (GradientPaint) p;
|
||||
result = 193;
|
||||
result = 37 * result + gp.getColor1().hashCode();
|
||||
result = 37 * result + gp.getPoint1().hashCode();
|
||||
result = 37 * result + gp.getColor2().hashCode();
|
||||
result = 37 * result + gp.getPoint2().hashCode();
|
||||
}
|
||||
else {
|
||||
// we assume that all other Paint instances implement equals() and
|
||||
// hashCode()...of course that might not be true, but what can we
|
||||
// do about it?
|
||||
result = p.hashCode();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for a <code>double[]</code> instance. If the array
|
||||
* is <code>null</code>, this method returns zero.
|
||||
*
|
||||
* @param a the array (<code>null</code> permitted).
|
||||
*
|
||||
* @return The hash code.
|
||||
*/
|
||||
public static int hashCodeForDoubleArray(double[] a) {
|
||||
if (a == null) {
|
||||
return 0;
|
||||
}
|
||||
int result = 193;
|
||||
long temp;
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
temp = Double.doubleToLongBits(a[i]);
|
||||
result = 29 * result + (int) (temp ^ (temp >>> 32));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and the value of a boolean
|
||||
* primitive.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param b the boolean value.
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static int hashCode(int pre, boolean b) {
|
||||
return 37 * pre + (b ? 0 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and the value of an int
|
||||
* primitive.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param i the int value.
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.8
|
||||
*/
|
||||
public static int hashCode(int pre, int i) {
|
||||
return 37 * pre + i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and the value of a double
|
||||
* primitive.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param d the double value.
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static int hashCode(int pre, double d) {
|
||||
long l = Double.doubleToLongBits(d);
|
||||
return 37 * pre + (int) (l ^ (l >>> 32));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and a paint instance.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param p the paint (<code>null</code> permitted).
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static int hashCode(int pre, Paint p) {
|
||||
return 37 * pre + hashCodeForPaint(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and a stroke instance.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param s the stroke (<code>null</code> permitted).
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static int hashCode(int pre, Stroke s) {
|
||||
int h = (s != null ? s.hashCode() : 0);
|
||||
return 37 * pre + h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and a string instance.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param s the string (<code>null</code> permitted).
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static int hashCode(int pre, String s) {
|
||||
int h = (s != null ? s.hashCode() : 0);
|
||||
return 37 * pre + h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and a <code>Comparable</code>
|
||||
* instance.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param c the comparable (<code>null</code> permitted).
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static int hashCode(int pre, Comparable c) {
|
||||
int h = (c != null ? c.hashCode() : 0);
|
||||
return 37 * pre + h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and an <code>Object</code>
|
||||
* instance.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.8
|
||||
*/
|
||||
public static int hashCode(int pre, Object obj) {
|
||||
int h = (obj != null ? obj.hashCode() : 0);
|
||||
return 37 * pre + h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a hash code for a {@link BooleanList}. In the latest version
|
||||
* of JCommon, the {@link BooleanList} class should implement the hashCode()
|
||||
* method correctly, but we compute it here anyway so that we can work with
|
||||
* older versions of JCommon (back to 1.0.0).
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param list the list (<code>null</code> permitted).
|
||||
*
|
||||
* @return The hash code.
|
||||
*
|
||||
* @since 1.0.9
|
||||
*/
|
||||
public static int hashCode(int pre, BooleanList list) {
|
||||
if (list == null) {
|
||||
return pre;
|
||||
}
|
||||
int result = 127;
|
||||
int size = list.size();
|
||||
result = HashUtilities.hashCode(result, size);
|
||||
|
||||
// for efficiency, we just use the first, last and middle items to
|
||||
// compute a hashCode...
|
||||
if (size > 0) {
|
||||
result = HashUtilities.hashCode(result, list.getBoolean(0));
|
||||
if (size > 1) {
|
||||
result = HashUtilities.hashCode(result,
|
||||
list.getBoolean(size - 1));
|
||||
if (size > 2) {
|
||||
result = HashUtilities.hashCode(result,
|
||||
list.getBoolean(size / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return 37 * pre + result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a hash code for a {@link PaintList}. In the latest version
|
||||
* of JCommon, the {@link PaintList} class should implement the hashCode()
|
||||
* method correctly, but we compute it here anyway so that we can work with
|
||||
* older versions of JCommon (back to 1.0.0).
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param list the list (<code>null</code> permitted).
|
||||
*
|
||||
* @return The hash code.
|
||||
*
|
||||
* @since 1.0.9
|
||||
*/
|
||||
public static int hashCode(int pre, PaintList list) {
|
||||
if (list == null) {
|
||||
return pre;
|
||||
}
|
||||
int result = 127;
|
||||
int size = list.size();
|
||||
result = HashUtilities.hashCode(result, size);
|
||||
|
||||
// for efficiency, we just use the first, last and middle items to
|
||||
// compute a hashCode...
|
||||
if (size > 0) {
|
||||
result = HashUtilities.hashCode(result, list.getPaint(0));
|
||||
if (size > 1) {
|
||||
result = HashUtilities.hashCode(result,
|
||||
list.getPaint(size - 1));
|
||||
if (size > 2) {
|
||||
result = HashUtilities.hashCode(result,
|
||||
list.getPaint(size / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return 37 * pre + result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a hash code for a {@link StrokeList}. In the latest version
|
||||
* of JCommon, the {@link StrokeList} class should implement the hashCode()
|
||||
* method correctly, but we compute it here anyway so that we can work with
|
||||
* older versions of JCommon (back to 1.0.0).
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param list the list (<code>null</code> permitted).
|
||||
*
|
||||
* @return The hash code.
|
||||
*
|
||||
* @since 1.0.9
|
||||
*/
|
||||
public static int hashCode(int pre, StrokeList list) {
|
||||
if (list == null) {
|
||||
return pre;
|
||||
}
|
||||
int result = 127;
|
||||
int size = list.size();
|
||||
result = HashUtilities.hashCode(result, size);
|
||||
|
||||
// for efficiency, we just use the first, last and middle items to
|
||||
// compute a hashCode...
|
||||
if (size > 0) {
|
||||
result = HashUtilities.hashCode(result, list.getStroke(0));
|
||||
if (size > 1) {
|
||||
result = HashUtilities.hashCode(result,
|
||||
list.getStroke(size - 1));
|
||||
if (size > 2) {
|
||||
result = HashUtilities.hashCode(result,
|
||||
list.getStroke(size / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return 37 * pre + result;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,154 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------------
|
||||
* LegendItemCollection.java
|
||||
* -------------------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 07-Feb-2002 : Version 1 (DG);
|
||||
* 24-Sep-2002 : Added get(int) and getItemCount() methods (DG);
|
||||
* 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 18-Apr-2005 : Added equals() method and implemented Cloneable and
|
||||
* Serializable (DG);
|
||||
* 23-Apr-2008 : Fixed clone() method (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
|
||||
/**
|
||||
* A collection of legend items.
|
||||
*/
|
||||
public class LegendItemCollection implements Cloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = 1365215565589815953L;
|
||||
|
||||
/** Storage for the legend items. */
|
||||
private List items;
|
||||
|
||||
/**
|
||||
* Constructs a new legend item collection, initially empty.
|
||||
*/
|
||||
public LegendItemCollection() {
|
||||
this.items = new java.util.ArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a legend item to the collection.
|
||||
*
|
||||
* @param item the item to add.
|
||||
*/
|
||||
public void add(LegendItem item) {
|
||||
this.items.add(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the legend items from another collection to this collection.
|
||||
*
|
||||
* @param collection the other collection.
|
||||
*/
|
||||
public void addAll(LegendItemCollection collection) {
|
||||
this.items.addAll(collection.items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a legend item from the collection.
|
||||
*
|
||||
* @param index the legend item index (zero-based).
|
||||
*
|
||||
* @return The legend item.
|
||||
*/
|
||||
public LegendItem get(int index) {
|
||||
return (LegendItem) this.items.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of legend items in the collection.
|
||||
*
|
||||
* @return The item count.
|
||||
*/
|
||||
public int getItemCount() {
|
||||
return this.items.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator that provides access to all the legend items.
|
||||
*
|
||||
* @return An iterator.
|
||||
*/
|
||||
public Iterator iterator() {
|
||||
return this.items.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this collection for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof LegendItemCollection)) {
|
||||
return false;
|
||||
}
|
||||
LegendItemCollection that = (LegendItemCollection) obj;
|
||||
if (!this.items.equals(that.items)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the collection.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if an item in the collection is not
|
||||
* cloneable.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
LegendItemCollection clone = (LegendItemCollection) super.clone();
|
||||
clone.items = (List) ObjectUtilities.deepClone(this.items);
|
||||
return clone;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------------
|
||||
* LegendItemSource.java
|
||||
* ---------------------
|
||||
* (C) Copyright 2005-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 23-Feb-2005 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
/**
|
||||
* A source of legend items. A {@link org.jfree.chart.title.LegendTitle} will
|
||||
* maintain a list of sources (often just one) from which it obtains legend
|
||||
* items.
|
||||
*/
|
||||
public interface LegendItemSource {
|
||||
|
||||
/**
|
||||
* Returns a (possibly empty) collection of legend items.
|
||||
*
|
||||
* @return The legend item collection (never <code>null</code>).
|
||||
*/
|
||||
public LegendItemCollection getLegendItems();
|
||||
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------------
|
||||
* LegendRenderingOrder.java
|
||||
* -------------------------
|
||||
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: Angel;
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 26-Mar-2004 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents the order for rendering legend items.
|
||||
*/
|
||||
public final class LegendRenderingOrder implements Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -3832486612685808616L;
|
||||
|
||||
/** In order. */
|
||||
public static final LegendRenderingOrder STANDARD
|
||||
= new LegendRenderingOrder("LegendRenderingOrder.STANDARD");
|
||||
|
||||
/** In reverse order. */
|
||||
public static final LegendRenderingOrder REVERSE
|
||||
= new LegendRenderingOrder("LegendRenderingOrder.REVERSE");
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
*
|
||||
* @param name the name.
|
||||
*/
|
||||
private LegendRenderingOrder(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the object.
|
||||
*
|
||||
* @return The string.
|
||||
*/
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this object is equal to the specified
|
||||
* object, and <code>false</code> otherwise.
|
||||
*
|
||||
* @param obj the other object.
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof LegendRenderingOrder)) {
|
||||
return false;
|
||||
}
|
||||
LegendRenderingOrder order = (LegendRenderingOrder) obj;
|
||||
if (!this.name.equals(order.toString())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that serialization returns the unique instances.
|
||||
*
|
||||
* @return The object.
|
||||
*
|
||||
* @throws ObjectStreamException if there is a problem.
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
if (this.equals(LegendRenderingOrder.STANDARD)) {
|
||||
return LegendRenderingOrder.STANDARD;
|
||||
}
|
||||
else if (this.equals(LegendRenderingOrder.REVERSE)) {
|
||||
return LegendRenderingOrder.REVERSE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file
|
||||
#
|
||||
# Changes (from 31-Aug-2003)
|
||||
# --------------------------
|
||||
# 31-Aug-2003 : Initial version (AL);
|
||||
#
|
||||
|
||||
Auto_Range=Auto Range
|
||||
All_Axes=Both Axes
|
||||
Chart_Properties=Chart Properties
|
||||
Copy=Copy
|
||||
Domain_Axis=Domain Axis
|
||||
PNG_Image_Files=PNG Image Files
|
||||
Print...=Print...
|
||||
Properties...=Properties...
|
||||
Save_as...=Save as...
|
||||
Range_Axis=Range Axis
|
||||
Zoom_In=Zoom In
|
||||
Zoom_Out=Zoom Out
|
||||
@@ -1,20 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file - german version
|
||||
#
|
||||
# Changes (from 31-Aug-2003)
|
||||
# --------------------------
|
||||
# 31-Aug-2003 : Initial version (AL);
|
||||
# 15-Mar-2004 : Revised version (Christian W. Zuckschwerdt);
|
||||
#
|
||||
|
||||
Auto_Range=Autojustage
|
||||
All_Axes=Beide Achsen
|
||||
Chart_Properties=Diagramm-Eigenschaften
|
||||
Copy=Kopieren
|
||||
Domain_Axis=Horizontale Achse
|
||||
PNG_Image_Files=PNG Datei (Portable Network Graphics) (*.png)
|
||||
Print...=Drucken...
|
||||
Properties...=Eigenschaften...
|
||||
Save_as...=Speichern unter...
|
||||
Range_Axis=Vertikale Achse
|
||||
Zoom_In=Hineinzoomen
|
||||
Zoom_Out=Herauszoomen
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file - spanish version
|
||||
#
|
||||
# Changes (from 16-Dec-2003)
|
||||
# --------------------------
|
||||
# 16-Dec-2003 : Initial Version: Complejo Hospitalario Universitario Juan Canalejo
|
||||
#
|
||||
|
||||
Auto_Range=Escala autom\u00E1tica
|
||||
All_Axes=Todos los ejes
|
||||
Chart_Properties=Propiedades del gr\u00E1fico
|
||||
Copy=Copiar
|
||||
Domain_Axis=Eje horizontal
|
||||
PNG_Image_Files=Formato PNG (Portable Network Graphics) (*.png)
|
||||
Print...=Imprimir...
|
||||
Properties...=Propiedades...
|
||||
Save_as...=Grabar como...
|
||||
Range_Axis=Eje vertical
|
||||
Zoom_In=Acercar
|
||||
Zoom_Out=Alejar
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file - french version
|
||||
#
|
||||
# Changes (from 31-Aug-2003)
|
||||
# --------------------------
|
||||
# 31-Aug-2003 : Initial version (AL);
|
||||
#
|
||||
|
||||
Auto_Range=Echelle automatique
|
||||
All_Axes=Les deux axes
|
||||
Chart_Properties=Propri\u00E9t\u00E9s du graphique
|
||||
Copy=Copier
|
||||
Domain_Axis=Axe horizontal
|
||||
PNG_Image_Files=Format PNG (Portable Network Graphics) (*.png)
|
||||
Print...=Imprimer...
|
||||
Properties...=Propri\u00E9t\u00E9s...
|
||||
Save_as...=Enregistrer sous...
|
||||
Range_Axis=Axe vertical
|
||||
Zoom_In=Zoom avant
|
||||
Zoom_Out=Zoom arri\u00E8re
|
||||
@@ -1,13 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file - italian version
|
||||
Auto_Range=Dimensiona Automaticamente
|
||||
All_Axes=Entrambi gli Assi
|
||||
Chart_Properties=Propriet\u00E0 del Grafico
|
||||
Copy=Copia
|
||||
Domain_Axis=Asse Orizzontale
|
||||
PNG_Image_Files=Immagine PNG
|
||||
Print...=Stampa...
|
||||
Properties...=Propriet\u00E0...
|
||||
Save_as...=Salva Come...
|
||||
Range_Axis=Asse Verticale
|
||||
Zoom_In=Ingrandisci
|
||||
Zoom_Out=Rimpicciolisci
|
||||
@@ -1,20 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file
|
||||
#
|
||||
# Changes (from 31-Aug-2003)
|
||||
# --------------------------
|
||||
# 24-Mar-2003 : Translated into Dutch
|
||||
# 31-Aug-2003 : Initial version (AL);
|
||||
#
|
||||
|
||||
Auto_Range=Automatisch bereik
|
||||
All_Axes=Beide assen
|
||||
Chart_Properties=Eigenschappen
|
||||
Copy=Kopie\u00EBren
|
||||
Domain_Axis=Horizontale As
|
||||
PNG_Image_Files=PNG afbeelding
|
||||
Print...=Afdrukken...
|
||||
Properties...=Eigenschappen...
|
||||
Save_as...=Opslaan als...
|
||||
Range_Axis=Verticale As
|
||||
Zoom_In=Inzoomen
|
||||
Zoom_Out=Uitzoomen
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file
|
||||
#
|
||||
# Changes (from 15-Mar-2004)
|
||||
# --------------------------
|
||||
# 15-Mar-2004 : Initial version (Kuba Duda);
|
||||
#
|
||||
|
||||
Auto_Range=Automatyczny zakres
|
||||
All_Axes=Obie osie
|
||||
Chart_Properties=W\u0142a\u015bciwo\u015bci wykresu
|
||||
Copy=Kopiuj
|
||||
Domain_Axis=O\u015b pozioma
|
||||
PNG_Image_Files=Pliki graficzne PNG
|
||||
Print...=Drukuj...
|
||||
Properties...=W\u0142a\u015bciwo\u015bci...
|
||||
Save_as...=Zapisz jako...
|
||||
Range_Axis=O\u015b pionowa
|
||||
Zoom_In=Powi\u0119ksz
|
||||
Zoom_Out=Pomniejsz
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file - portuguese version
|
||||
#
|
||||
# Changes (from 24-May-2007)
|
||||
# --------------------------
|
||||
# 24-May-2007 : Initial version (Leonardo Alves Machado);
|
||||
#
|
||||
|
||||
Auto_Range=Escala autom\u00E1tica
|
||||
All_Axes=Todos os eixos
|
||||
Chart_Properties=Propriedades do gr\u00E1fico
|
||||
Copy=Copiar
|
||||
Domain_Axis=Eixo horizontal
|
||||
PNG_Image_Files=Formato PNG (Portable Network Graphics) (*.png)
|
||||
Print...=Imprimir...
|
||||
Properties...=Propriedades...
|
||||
Save_as...=Salvar como...
|
||||
Range_Axis=Eixo vertical
|
||||
Zoom_In=Ampliar
|
||||
Zoom_Out=Reduzir
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file - portuguese version
|
||||
#
|
||||
# Changes (from 09-Set-2003)
|
||||
# --------------------------
|
||||
# 09-Set-2003 : Initial version (ER);
|
||||
#
|
||||
|
||||
Auto_Range=Escala autom\u00E1tica
|
||||
All_Axes=Todos os eixos
|
||||
Chart_Properties=Propriedades do gr\u00E1fico
|
||||
Copy=Copiar
|
||||
Domain_Axis=Eixo horizontal
|
||||
PNG_Image_Files=Formato PNG (Portable Network Graphics) (*.png)
|
||||
Print...=Imprimir...
|
||||
Properties...=Propriedades...
|
||||
Save_as...=Gravar como...
|
||||
Range_Axis=Eixo vertical
|
||||
Zoom_In=Aproximar
|
||||
Zoom_Out=Afastar
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file
|
||||
#
|
||||
# Changes (from 10-Nov-2003)
|
||||
# --------------------------
|
||||
# 10-Nov-2003 : Initial version (AL);
|
||||
#
|
||||
|
||||
Auto_Range=\u0410\u0432\u0442\u043e\u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435
|
||||
All_Axes=\u041f\u043e \u0432\u0441\u0435\u043c \u043e\u0441\u044f\u043c
|
||||
Chart_Properties=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430
|
||||
Copy=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c
|
||||
Domain_Axis=\u041f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0441\u0438
|
||||
PNG_Image_Files=PNG \u0444\u0430\u0439\u043b
|
||||
Print...=\u041f\u0435\u0447\u0430\u0442\u044c...
|
||||
Properties...=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438...
|
||||
Save_as...=\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0430\u043a...
|
||||
Range_Axis=\u041f\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0441\u0438
|
||||
Zoom_In=\u041f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u044c
|
||||
Zoom_Out=\u041e\u0442\u0434\u0430\u043b\u0438\u0442\u044c
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file
|
||||
#
|
||||
# Changes
|
||||
# -------
|
||||
# 29-Jun-2005 : Initial version, see: http://www.jfree.org/phpBB2/viewtopic.php?t=13495;
|
||||
#
|
||||
|
||||
Auto_Range=\u81ea\u52a8\u8c03\u6574
|
||||
All_Axes=\u6240\u6709\u8f74
|
||||
Chart_Properties=\u56fe\u8868\u5c5e\u6027
|
||||
Copy=\u590d\u5236
|
||||
Domain_Axis=\u6c34\u5e73\u8f74
|
||||
PNG_Image_Files=PNG \u683c\u5f0f\u7684\u56fe\u50cf
|
||||
Print...=\u6253\u5370
|
||||
Properties...=\u5c5e\u6027
|
||||
Save_as...=\u53e6\u5b58\u4e3a
|
||||
Range_Axis=\u5782\u76f4\u8f74
|
||||
Zoom_In=\u653e\u5927
|
||||
Zoom_Out=\u7f29\u5c0f
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file
|
||||
#
|
||||
# Changes (from 31-Aug-2003)
|
||||
# --------------------------
|
||||
# 31-Aug-2003 : Initial version (AL);
|
||||
#
|
||||
|
||||
Auto_Range=\u81ea\u52d5\u8abf\u6574
|
||||
All_Axes=\u6240\u6709\u8ef8
|
||||
Chart_Properties=\u5716\u8868\u5167\u5bb9
|
||||
Copy=\u8907\u88fd
|
||||
Domain_Axis=\u6a6b\u8ef8
|
||||
PNG_Image_Files=PNG\u5716\u6a94
|
||||
Print...=\u5217\u5370
|
||||
Properties...=\u5167\u5bb9
|
||||
Save_as...=\u53e6\u5b58\u65b0\u6a94
|
||||
Range_Axis=\u7e31\u8ef8
|
||||
Zoom_In=\u653e\u5927
|
||||
Zoom_Out=\u7e2e\u5c0f
|
||||
@@ -1,222 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------
|
||||
* PaintMap.java
|
||||
* -------------
|
||||
* (C) Copyright 2006-2015, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 27-Sep-2006 : Version 1 (DG);
|
||||
* 17-Jan-2007 : Changed TreeMap to HashMap, so that different classes that
|
||||
* implement Comparable can be used as keys (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.Paint;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.util.PaintUtilities;
|
||||
|
||||
/**
|
||||
* A storage structure that maps <code>Comparable</code> instances with
|
||||
* <code>Paint</code> instances.
|
||||
* <br><br>
|
||||
* To support cloning and serialization, you should only use keys that are
|
||||
* cloneable and serializable. Special handling for the <code>Paint</code>
|
||||
* instances is included in this class.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*/
|
||||
public class PaintMap implements Cloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
static final long serialVersionUID = -4639833772123069274L;
|
||||
|
||||
/** Storage for the keys and values. */
|
||||
private transient Map store;
|
||||
|
||||
/**
|
||||
* Creates a new (empty) map.
|
||||
*/
|
||||
public PaintMap() {
|
||||
this.store = new HashMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the paint associated with the specified key, or
|
||||
* <code>null</code>.
|
||||
*
|
||||
* @param key the key (<code>null</code> not permitted).
|
||||
*
|
||||
* @return The paint, or <code>null</code>.
|
||||
*
|
||||
* @throws IllegalArgumentException if <code>key</code> is
|
||||
* <code>null</code>.
|
||||
*/
|
||||
public Paint getPaint(Comparable key) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("Null 'key' argument.");
|
||||
}
|
||||
return (Paint) this.store.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the map contains the specified key, and
|
||||
* <code>false</code> otherwise.
|
||||
*
|
||||
* @param key the key.
|
||||
*
|
||||
* @return <code>true</code> if the map contains the specified key, and
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean containsKey(Comparable key) {
|
||||
return this.store.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a mapping between the specified <code>key</code> and
|
||||
* <code>paint</code> values.
|
||||
*
|
||||
* @param key the key (<code>null</code> not permitted).
|
||||
* @param paint the paint.
|
||||
*
|
||||
* @throws IllegalArgumentException if <code>key</code> is
|
||||
* <code>null</code>.
|
||||
*/
|
||||
public void put(Comparable key, Paint paint) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("Null 'key' argument.");
|
||||
}
|
||||
this.store.put(key, paint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the map to empty.
|
||||
*/
|
||||
public void clear() {
|
||||
this.store.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this map for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof PaintMap)) {
|
||||
return false;
|
||||
}
|
||||
PaintMap that = (PaintMap) obj;
|
||||
if (this.store.size() != that.store.size()) {
|
||||
return false;
|
||||
}
|
||||
Set keys = this.store.keySet();
|
||||
Iterator iterator = keys.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Comparable key = (Comparable) iterator.next();
|
||||
Paint p1 = getPaint(key);
|
||||
Paint p2 = that.getPaint(key);
|
||||
if (!PaintUtilities.equal(p1, p2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of this <code>PaintMap</code>.
|
||||
*
|
||||
* @return A clone of this instance.
|
||||
*
|
||||
* @throws CloneNotSupportedException if any key is not cloneable.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
// TODO: I think we need to make sure the keys are actually cloned,
|
||||
// whereas the paint instances are always immutable so they're OK
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
stream.writeInt(this.store.size());
|
||||
Set keys = this.store.keySet();
|
||||
Iterator iterator = keys.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Comparable key = (Comparable) iterator.next();
|
||||
stream.writeObject(key);
|
||||
Paint paint = getPaint(key);
|
||||
SerialUtilities.writePaint(paint, stream);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.store = new HashMap();
|
||||
int keyCount = stream.readInt();
|
||||
for (int i = 0; i < keyCount; i++) {
|
||||
Comparable key = (Comparable) stream.readObject();
|
||||
Paint paint = SerialUtilities.readPaint(stream);
|
||||
this.store.put(key, paint);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* --------------------
|
||||
* PolarChartPanel.java
|
||||
* --------------------
|
||||
* (C) Copyright 2004-2008, by Solution Engineering, Inc. and Contributors.
|
||||
*
|
||||
* Original Author: Daniel Bridenbecker, Solution Engineering, Inc.;
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 19-Jan-2004 : Version 1, contributed by DB with minor changes by DG (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PolarPlot;
|
||||
|
||||
/**
|
||||
* <code>PolarChartPanel</code> is the top level object for using the
|
||||
* {@link PolarPlot}. Since this class has a <code>JPanel</code> in the
|
||||
* inheritance hierarchy, one uses this class to integrate the Polar plot into
|
||||
* their application.
|
||||
* <p>
|
||||
* The main modification to <code>ChartPanel</code> is the popup menu. It
|
||||
* removes <code>ChartPanel</code>'s versions of:
|
||||
* <ul>
|
||||
* <li><code>Zoom In</code></li>
|
||||
* <li><code>Zoom Out</code></li>
|
||||
* <li><code>Auto Range</code></li>
|
||||
* </ul>
|
||||
* and replaces them with versions more appropriate for {@link PolarPlot}.
|
||||
*/
|
||||
public class PolarChartPanel extends ChartPanel {
|
||||
|
||||
// -----------------
|
||||
// --- Constants ---
|
||||
// -----------------
|
||||
|
||||
/** Zoom in command string. */
|
||||
private static final String POLAR_ZOOM_IN_ACTION_COMMAND = "Polar Zoom In";
|
||||
|
||||
/** Zoom out command string. */
|
||||
private static final String POLAR_ZOOM_OUT_ACTION_COMMAND
|
||||
= "Polar Zoom Out";
|
||||
|
||||
/** Auto range command string. */
|
||||
private static final String POLAR_AUTO_RANGE_ACTION_COMMAND
|
||||
= "Polar Auto Range";
|
||||
|
||||
// ------------------------
|
||||
// --- Member Variables ---
|
||||
// ------------------------
|
||||
|
||||
// --------------------
|
||||
// --- Constructors ---
|
||||
// --------------------
|
||||
/**
|
||||
* Constructs a JFreeChart panel.
|
||||
*
|
||||
* @param chart the chart.
|
||||
*/
|
||||
public PolarChartPanel(JFreeChart chart) {
|
||||
this(chart, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new panel.
|
||||
*
|
||||
* @param chart the chart.
|
||||
* @param useBuffer buffered?
|
||||
*/
|
||||
public PolarChartPanel(JFreeChart chart, boolean useBuffer) {
|
||||
super(chart, useBuffer);
|
||||
checkChart(chart);
|
||||
setMinimumDrawWidth(200);
|
||||
setMinimumDrawHeight(200);
|
||||
setMaximumDrawWidth(2000);
|
||||
setMaximumDrawHeight(2000);
|
||||
}
|
||||
|
||||
// --------------------------
|
||||
// --- ChartPanel Methods ---
|
||||
// --------------------------
|
||||
/**
|
||||
* Sets the chart that is displayed in the panel.
|
||||
*
|
||||
* @param chart The chart.
|
||||
*/
|
||||
public void setChart(JFreeChart chart) {
|
||||
checkChart(chart);
|
||||
super.setChart(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a popup menu for the panel.
|
||||
*
|
||||
* @param properties include a menu item for the chart property editor.
|
||||
* @param save include a menu item for saving the chart.
|
||||
* @param print include a menu item for printing the chart.
|
||||
* @param zoom include menu items for zooming.
|
||||
*
|
||||
* @return The popup menu.
|
||||
*/
|
||||
protected JPopupMenu createPopupMenu(boolean properties,
|
||||
boolean save,
|
||||
boolean print,
|
||||
boolean zoom) {
|
||||
|
||||
JPopupMenu result = super.createPopupMenu(properties, save, print, zoom);
|
||||
int zoomInIndex = getPopupMenuItem(result, "Zoom In");
|
||||
int zoomOutIndex = getPopupMenuItem(result, "Zoom Out");
|
||||
int autoIndex = getPopupMenuItem(result, "Auto Range");
|
||||
if (zoom) {
|
||||
JMenuItem zoomIn = new JMenuItem("Zoom In");
|
||||
zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND);
|
||||
zoomIn.addActionListener(this);
|
||||
|
||||
JMenuItem zoomOut = new JMenuItem("Zoom Out");
|
||||
zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND);
|
||||
zoomOut.addActionListener(this);
|
||||
|
||||
JMenuItem auto = new JMenuItem("Auto Range");
|
||||
auto.setActionCommand(POLAR_AUTO_RANGE_ACTION_COMMAND);
|
||||
auto.addActionListener(this);
|
||||
|
||||
if (zoomInIndex != -1) {
|
||||
result.remove(zoomInIndex);
|
||||
}
|
||||
else {
|
||||
zoomInIndex = result.getComponentCount() - 1;
|
||||
}
|
||||
result.add(zoomIn, zoomInIndex);
|
||||
if (zoomOutIndex != -1) {
|
||||
result.remove(zoomOutIndex);
|
||||
}
|
||||
else {
|
||||
zoomOutIndex = zoomInIndex + 1;
|
||||
}
|
||||
result.add(zoomOut, zoomOutIndex);
|
||||
if (autoIndex != -1) {
|
||||
result.remove(autoIndex);
|
||||
}
|
||||
else {
|
||||
autoIndex = zoomOutIndex + 1;
|
||||
}
|
||||
result.add(auto, autoIndex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles action events generated by the popup menu.
|
||||
*
|
||||
* @param event the event.
|
||||
*/
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
String command = event.getActionCommand();
|
||||
|
||||
if (command.equals(POLAR_ZOOM_IN_ACTION_COMMAND)) {
|
||||
PolarPlot plot = (PolarPlot) getChart().getPlot();
|
||||
plot.zoom(0.5);
|
||||
}
|
||||
else if (command.equals(POLAR_ZOOM_OUT_ACTION_COMMAND)) {
|
||||
PolarPlot plot = (PolarPlot) getChart().getPlot();
|
||||
plot.zoom(2.0);
|
||||
}
|
||||
else if (command.equals(POLAR_AUTO_RANGE_ACTION_COMMAND)) {
|
||||
PolarPlot plot = (PolarPlot) getChart().getPlot();
|
||||
plot.getAxis().setAutoRange(true);
|
||||
}
|
||||
else {
|
||||
super.actionPerformed(event);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
// --- Public Methods ---
|
||||
// ----------------------
|
||||
|
||||
// -----------------------
|
||||
// --- Private Methods ---
|
||||
// -----------------------
|
||||
|
||||
/**
|
||||
* Test that the chart is using an xy plot with time as the domain axis.
|
||||
*
|
||||
* @param chart the chart.
|
||||
*/
|
||||
private void checkChart(JFreeChart chart) {
|
||||
Plot plot = chart.getPlot();
|
||||
if (!(plot instanceof PolarPlot)) {
|
||||
throw new IllegalArgumentException("plot is not a PolarPlot");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of an item in a popup menu.
|
||||
*
|
||||
* @param menu the menu.
|
||||
* @param text the label.
|
||||
*
|
||||
* @return The item index.
|
||||
*/
|
||||
private int getPopupMenuItem(JPopupMenu menu, String text) {
|
||||
int index = -1;
|
||||
for (int i = 0; (index == -1) && (i < menu.getComponentCount()); i++) {
|
||||
Component comp = menu.getComponent(i);
|
||||
if (comp instanceof JMenuItem) {
|
||||
JMenuItem item = (JMenuItem) comp;
|
||||
if (text.equals(item.getText())) {
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user