Skip to main content
summaryrefslogtreecommitdiffstats
blob: 132fd3a2d88da01b9f52010fe63f4216053e1eaa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*=============================================================================#
 # Copyright (c) 2009, 2021 Stephan Wahlbrink and others.
 # 
 # This program and the accompanying materials are made available under the
 # terms of the Eclipse Public License 2.0 which is available at
 # https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
 # which is available at https://www.apache.org/licenses/LICENSE-2.0.
 # 
 # SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
 # 
 # Contributors:
 #     Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
 #=============================================================================*/

package org.eclipse.statet.rj.server.client;

import org.eclipse.statet.jcommons.status.ProgressMonitor;

import org.eclipse.statet.rj.graphic.core.RCircle;
import org.eclipse.statet.rj.graphic.core.RClipSetting;
import org.eclipse.statet.rj.graphic.core.RColorSetting;
import org.eclipse.statet.rj.graphic.core.RFillSetting;
import org.eclipse.statet.rj.graphic.core.RFontSetting;
import org.eclipse.statet.rj.graphic.core.RLine;
import org.eclipse.statet.rj.graphic.core.RLineSetting;
import org.eclipse.statet.rj.graphic.core.RPath;
import org.eclipse.statet.rj.graphic.core.RPolygon;
import org.eclipse.statet.rj.graphic.core.RPolyline;
import org.eclipse.statet.rj.graphic.core.RRaster;
import org.eclipse.statet.rj.graphic.core.RRect;
import org.eclipse.statet.rj.graphic.core.RText;
import org.eclipse.statet.rj.services.RService;


/**
 * Interface for the R side of (RJ) graphics at client layer.
 * 
 * The methods are called by the client protocol handler
 * (e.g. {@link AbstractRJComClient}) and must not be called at
 * another place.
 */
public interface RClientGraphic {
	
	
	class InitConfig {
		
		public int canvasColor;
		
	}
	
	
	/**
	 * Mask for fill rule
	 * <ul>
	 *   <li>{@link #FILL_WIND_EVEN_ODD}</li>
	 *   <li>{@link #FILL_WIND_NON_ZERO}</li>
	 * </ul>
	 * 
	 * @since 2.0
	 */
	int MASK_FILL_RULE= 0x3;
	
	/**
	 * Constant for "even-odd" winding rule for filling elements
	 * 
	 * @since 2.0
	 */
	int FILL_WIND_EVEN_ODD= 0x0;
	
	/**
	 * Constant for "non-zero" winding rule for filling elements
	 * 
	 * @since 2.0
	 */
	int FILL_WIND_NON_ZERO= 0x1;
	
	
	/**
	 * Returns the device id of R
	 * 
	 * @return the id
	 */
	int getDevId();
	
	/**
	 * 
	 * @param w the width of the graphic
	 * @param h the height of the graphic
	 * @param config initialization configuration
	 */
	void reset(double w, double h, InitConfig config);
	
	/**
	 * Sets if the graphic is the active device in R.
	 * 
	 * @param active <code>true</code> if active, otherwise <code>false</code>
	 */
	void setActive(boolean active);
	
	/**
	 * Returns if the graphic is the active device in R.
	 * 
	 * @return <code>true</code> if active, otherwise <code>false</code>
	 */
	boolean isActive();
	
	/**
	 * Sets the current mode signaled by R.
	 * <p>
	 * Values:
	 *     0= R stopped drawing
	 *     1= R started drawing
	 *     2= graphical input exists
	 * 
	 * @param mode the value constant
	 */
	void setMode(int mode);
	
	double[] computeSize();
	double[] computeFontMetric(int ch);
	double[] computeStringWidth(String txt);
	
	/**
	 * @see RClipSetting#RClipSetting(double, double, double, double)
	 */
	void addSetClip(double x0, double y0, double x1, double y1);
	/**
	 * @see RColorSetting#RColorSetting(int)
	 */
	void addSetColor(int color);
	/**
	 * @see RFillSetting#RFillSetting(int)
	 */
	void addSetFill(int color);
	/**
	 * @see RLineSetting#RLineSetting(int, double, byte, byte, float)
	 */
	void addSetLine(int type, float width, byte cap, byte join, float joinMiterLimit);
	/**
	 * @see RFontSetting#RFontSetting(String, int, double, double, double)
	 */
	void addSetFont(String family, int face, float pointSize, float lineHeight);
	/**
	 * @see RLine#RLine(double, double, double, double)
	 */
	void addDrawLine(double x0, double y0, double x1, double y1);
	/**
	 * @see RRect#RRect(double, double, double, double)
	 */
	void addDrawRect(double x0, double y0, double x1, double y1);
	/**
	 * @see RPolyline
	 */
	void addDrawPolyline(double[] x, double[] y);
	/**
	 * @see RPolygon
	 */
	void addDrawPolygon(double[] x, double[] y);
	/**
	 * @see RPath
	 */
	void addDrawPath(int[] n, double[] x, double[] y, int winding);
	/**
	 * @see RCircle#RCircle(double, double, double)
	 */
	void addDrawCircle(double x, double y, double r);
	/**
	 * @see RText
	 */
	void addDrawText(String txt, double x, double y, double rDeg, double hAdj);
	/**
	 * @see RRaster
	 */
	void addDrawRaster(byte[] imgData, boolean imgAlpha, int imgWidth, int imgHeight,
			double x, double y, double w, double h, double rDeg, boolean interpolate);
	
	byte[] capture(int width, int height);
	
	
	double[] runRLocator(RService r, ProgressMonitor m);
	
}

Back to the top