* In an xml layout:
*
*
@@ -132,14 +173,15 @@ public abstract class Plot
*
- *
+ *
* Programatically:
*
*
* XYPlot myPlot = new XYPlot(context "MyPlot", Plot.RenderMode.USE_MAIN_THREAD);
*
- *
+ *
* A Plot's RenderMode cannot be changed after the plot has been initialized.
+ *
* @since 0.5.1
*/
public enum RenderMode {
@@ -148,8 +190,9 @@ public abstract class Plot
* XML value: use_background_thread
+ *
* @since 0.5.1
*/
USE_BACKGROUND_THREAD,
@@ -158,61 +201,38 @@ public abstract class Plot
* XML value: use_main_thread
+ *
* @since 0.5.1
*/
USE_MAIN_THREAD
}
- private BoxModel boxModel = new BoxModel();
-
- // no border by default:
- private BorderStyle borderStyle = Plot.BorderStyle.NONE;
- private float borderRadiusX = 15;
- private float borderRadiusY = 15;
- private Paint borderPaint;
- private Paint backgroundPaint;
- private LayoutManager layoutManager;
- private TextLabelWidget title;
- private DisplayDimensions displayDims = new DisplayDimensions();
- private RenderMode renderMode = RenderMode.USE_MAIN_THREAD;
- private final BufferedCanvas pingPong = new BufferedCanvas();
-
- // used to get rid of flickering when drawing offScreenBitmap to the visible Canvas.
- private final Object renderSync = new Object();
-
- private HashMap, RendererType> renderers;
-
- private RegistryType registry;
- private final ArrayList listeners;
-
- private Thread renderThread;
- private boolean keepRunning = false;
- private boolean isIdle = true;
{
listeners = new ArrayList<>();
registry = getRegistryInstance();
renderers = new HashMap<>();
-
borderPaint = new Paint();
- borderPaint.setColor(Color.rgb(150, 150, 150));
- borderPaint.setStyle(Paint.Style.STROKE);
+ borderPaint.setColor(new Color(Color.rgb(150, 150, 150)));
+ borderPaint.setStyle(Paint.Style.STROKE_STYLE);
borderPaint.setStrokeWidth(1.0f);
borderPaint.setAntiAlias(true);
backgroundPaint = new Paint();
backgroundPaint.setColor(Color.DKGRAY);
- backgroundPaint.setStyle(Paint.Style.FILL);
+ backgroundPaint.setStyle(Paint.Style.FILL_STYLE);
}
/**
- * Any rendering that utilizes a buffer from this class should synchronize rendering on the instance of this class
- * that is being used.
+ * Any rendering that utilizes a buffer from this class should synchronize rendering on the instance of this class
+ * that is being used.
+ *
+ * @since 2021-07-23
*/
private static class BufferedCanvas {
- private volatile Bitmap bgBuffer; // all drawing is done on this buffer.
- private volatile Bitmap fgBuffer;
+ private volatile PixelMap bgBuffer;
+ private volatile PixelMap fgBuffer;
private Canvas canvas = new Canvas();
/**
@@ -220,7 +240,7 @@ public abstract class Plot
* if(getClass().equals(DerivedPlot.class) {
- * loadAttrs(context, attrs);
+ * loadAttrs(context, attrs);
* }
*
- *
- * See {@link com.androidplot.xy.XYPlot#XYPlot(android.content.Context, android.util.AttributeSet)}
+ *
+ * See
* for an example.
+ *
* @param context
* @param attrs
*/
- public Plot(Context context, AttributeSet attrs) {
+ public Plot(Context context, AttrSet attrs) {
super(context, attrs);
init(context, attrs, 0);
}
@@ -330,17 +361,17 @@ public abstract class Plot
* if(getClass().equals(DerivedPlot.class) {
- * loadAttrs(context, attrs);
+ * loadAttrs(context, attrs);
* }
*
- *
- * See {@link com.androidplot.xy.XYPlot#XYPlot(android.content.Context, android.util.AttributeSet, int)}
+ *
* for an example.
+ *
* @param context
* @param attrs
* @param defStyle
*/
- public Plot(Context context, AttributeSet attrs, int defStyle) {
+ public Plot(Context context, AttrSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs, defStyle);
}
@@ -348,6 +379,7 @@ public abstract class Plot {
+ invalidate();
+ });
// prevent this thread from becoming an orphan
// after the view is destroyed
if (keepRunning) {
@@ -434,54 +507,127 @@ public abstract class Plot attrHash = new HashMap<>();
- for (int i = 0; i < attrs.getAttributeCount(); i++) {
- String attrName = attrs.getAttributeName(i);
-
- // case insensitive run to see if this attr begins with our prefix:
- if (attrName != null && attrName.toUpperCase().startsWith(XML_ATTR_PREFIX.toUpperCase())) {
- attrHash.put(attrName.substring(XML_ATTR_PREFIX.length() + 1), attrs.getAttributeValue(i));
- }
- }
- try {
- Fig.configure(getContext(), this, attrHash);
- } catch (FigException e) {
- throw new RuntimeException(e);
- }
+ processAttrs(attrs);
+ processBaseAttrs(attrs);
}
}
@@ -569,10 +649,22 @@ public abstract class Plot getSeries(SeriesType series, Class extends RendererType> rendererClass) {
- for(SeriesBundle thisPair : getSeries(series)) {
- if(thisPair.getFormatter().getRendererClass() == rendererClass) {
+ for (SeriesBundle thisPair : getSeries(series)) {
+ if (thisPair.getFormatter().getRendererClass() == rendererClass) {
return thisPair;
}
}
@@ -654,6 +760,7 @@ public abstract class Plot rendererClass) {
-
List removedItems = getRegistry().remove(series, rendererClass);
-
- // if series implements PlotListener and is not assigned to any other renderers remove it as a listener:
if (removedItems.size() == 1 && series instanceof PlotListener) {
removeListener((PlotListener) series);
return true;
@@ -684,6 +788,7 @@ public abstract class Plot
+ * @return (T) getRenderers().get(rendererClass)
+ */
public T getRenderer(Class rendererClass) {
return (T) getRenderers().get(rendererClass);
}
@@ -729,34 +842,35 @@ public abstract class Plot(getRenderers().values());
}
+ /**
+ * setMarkupEnabled
+ *
+ * @param enabled
+ */
public void setMarkupEnabled(boolean enabled) {
this.layoutManager.setMarkupEnabled(enabled);
}
/**
* Causes the plot to be redrawn.
+ *
+ * @throws IllegalArgumentException
* @since 0.5.1
*/
public void redraw() {
-
if (renderMode == RenderMode.USE_BACKGROUND_THREAD) {
-
- // only enter synchronized block if the call is expected to block OR
- // if the render thread is idle, so we know that we won't have to wait to
- // obtain a lock.
if (isIdle) {
synchronized (renderSync) {
renderSync.notify();
}
}
- } else if(renderMode == RenderMode.USE_MAIN_THREAD) {
-
- // are we on the UI thread?
- if (Looper.myLooper() == Looper.getMainLooper()) {
+ } else if (renderMode == RenderMode.USE_MAIN_THREAD) {
+ /**
+ * 更新UI的操作
+ */
+ getContext().getUITaskDispatcher().asyncDispatch(() -> {
invalidate();
- } else {
- postInvalidate();
- }
+ });
} else {
throw new IllegalArgumentException("Unsupported Render Mode: " + renderMode);
}
@@ -768,121 +882,58 @@ public abstract class Plot= 11) {
- if (!isHwAccelerationSupported() && isHardwareAccelerated()) {
- setLayerType(View.LAYER_TYPE_SOFTWARE, null);
- }
- }
-
- // pingPong is only used in background rendering mode.
- if(renderMode == RenderMode.USE_BACKGROUND_THREAD) {
- pingPong.resize(h, w);
- }
-
- RectF cRect = new RectF(0, 0, w, h);
- RectF mRect = boxModel.getMarginatedRect(cRect);
- RectF pRect = boxModel.getPaddedRect(mRect);
-
- layout(new DisplayDimensions(cRect, mRect, pRect));
- super.onSizeChanged(w, h, oldw, oldh);
- if(renderThread != null && !renderThread.isAlive()) {
- renderThread.start();
- }
- }
/**
* Called whenever the plot needs to be drawn via the Handler, which invokes invalidate().
* Should never be called directly; use {@link #redraw()} instead.
+ *
* @param canvas
*/
- @Override
- protected void onDraw(Canvas canvas) {
- if (renderMode == RenderMode.USE_BACKGROUND_THREAD) {
- synchronized(pingPong) {
- Bitmap bmp = pingPong.getBitmap();
- if(bmp != null) {
- canvas.drawBitmap(bmp, 0, 0, null);
- }
- }
- } else if (renderMode == RenderMode.USE_MAIN_THREAD) {
- renderOnCanvas(canvas);
- } else {
- throw new IllegalArgumentException("Unsupported Render Mode: " + renderMode);
- }
- }
+
/**
* Renders the plot onto a canvas. Used by both main thread to draw directly
* onto the View's canvas as well as by background draw to render onto a
* Bitmap buffer. At the end of the day this is the main entry for a plot's
* "heavy lifting".
+ *
* @param canvas
*/
protected synchronized void renderOnCanvas(@Nullable Canvas canvas) {
- if(canvas == null) {
+ if (canvas == null) {
return;
}
try {
- // any series interested in synchronizing with plot should
- // implement PlotListener.onBeforeDraw(...) and do a read lock from within its
- // invocation. This is the entry point into that call:
notifyListenersBeforeDraw(canvas);
- try {
- // need to completely erase what was on the canvas before redrawing, otherwise
- // some odd aliasing artifacts begin to build up around the edges of aa'd entities
- // over time.
- canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
- if (backgroundPaint != null) {
- drawBackground(canvas, displayDims.marginatedRect);
- }
+ canvas.drawColor(Color.TRANSPARENT
+ .getValue(), BlendMode.CLEAR);
+ if (backgroundPaint != null) {
+ drawBackground(canvas, displayDims.marginatedRect);
+ }
- layoutManager.draw(canvas);
+ layoutManager.draw(canvas);
- if (getBorderPaint() != null) {
- drawBorder(canvas, displayDims.marginatedRect);
- }
- } catch (Exception e) {
- Log.e(TAG, "Exception while rendering Plot.", e);
+ if (getBorderPaint() != null) {
+ drawBorder(canvas, displayDims.marginatedRect);
}
-
isIdle = true;
- // any series interested in synchronizing with plot should
- // implement PlotListener.onAfterDraw(...) and do a read unlock from within that
- // invocation. This is the entry point for that invocation.
notifyListenersAfterDraw(canvas);
} finally {
+ Logger.getLogger(Plot.class.getName()).log(Level.SEVERE, "FINAL");
}
}
-
/**
* Sets the visual style of the plot's border.
+ *
* @param style
* @param radiusX Sets the X radius for BorderStyle.ROUNDED. Use null for all other styles.
* @param radiusY Sets the Y radius for BorderStyle.ROUNDED. Use null for all other styles.
+ * @throws IllegalArgumentException
*/
public void setBorderStyle(BorderStyle style, Float radiusX, Float radiusY) {
- if (style == Plot.BorderStyle.ROUNDED) {
- if (radiusX == null || radiusY == null){
+ if (style == BorderStyle.ROUNDED) {
+ if (radiusX == null || radiusY == null) {
throw new IllegalArgumentException("radiusX and radiusY cannot be null when using BorderStyle.ROUNDED");
}
this.borderRadiusX = radiusX;
@@ -893,17 +944,32 @@ public abstract class Plot getStyleMap() {
+ return mStyleMap;
+ }
+
public Paint getBackgroundPaint() {
return backgroundPaint;
}
@@ -933,6 +1003,7 @@ public abstract class Plot= getMin().doubleValue() && value.doubleValue() <= getMax().doubleValue();
}
+ /**
+ * intersects
+ *
+ * @param region
+ * @return intersects
+ */
public boolean intersects(Region region) {
return intersects(region.getMin(), region.getMax());
}
/**
+ * Tests whether this segment intersects another
+ *
+ * @param line2Min
+ * @param line2Max
+ * @return contains
+ */
+ public boolean intersects(Number line2Min, Number line2Max) {
+ if (line2Min.doubleValue() <= getMin().doubleValue() && line2Max.doubleValue() >= getMax().doubleValue()) {
+ return true;
+ } else {
+ return contains(line2Min) || contains(line2Max);
+ }
+ }
+
+ /**
+ * center
*
* @return Middle value within this region
*/
@@ -101,57 +152,82 @@ public class Region {
/**
* Transform a value relative to this region into it's corresponding value relative to the
* specified region.
+ *
* @param value
* @param region2
- * @return
+ * @return transform
*/
public Number transform(double value, Region region2) {
return transform(value, region2, false);
}
+ /**
+ * transform
+ *
+ * @param value
+ * @param region2
+ * @param flip
+ * @return transform
+ */
public Number transform(double value, Region region2, boolean flip) {
return transform(value, region2.getMin().doubleValue(), region2.getMax().doubleValue(), flip);
}
- public double transform(double value, double min, double max, boolean flip) {
+ /**
+ * transform
+ *
+ * @param value
+ * @param tfMin
+ * @param tfmax
+ * @param flip
+ * @return tf
+ */
+ public double transform(double value, double tfMin, double tfmax, boolean flip) {
double range = length().doubleValue();
- final double r2 = max - min;
-
- // TODO: refactor to use ratio here
+ final double r2 = tfmax - tfMin;
final double scale = r2 / range;
- if(!flip) {
- return min + (scale * (value - this.getMin().doubleValue()));
+ if (!flip) {
+ return tfMin + (scale * (value - this.getMin().doubleValue()));
} else {
- return max - (scale * (value - this.getMin().doubleValue()));
+ return tfmax - (scale * (value - this.getMin().doubleValue()));
}
}
+ /**
+ * ratio
+ *
+ * @param r2
+ * @return ratio
+ */
public Number ratio(Region r2) {
return ratio(r2.getMin().doubleValue(), r2.getMax().doubleValue());
}
/**
+ * ratio
*
- * @param min
- * @param max
+ * @param dbMin
+ * @param dbMax
* @return length of this series divided by the length of the distance between min and max.
*/
- public double ratio(double min, double max) {
- return length().doubleValue() / (max - min);
+ public double ratio(double dbMin, double dbMax) {
+ return length().doubleValue() / (dbMax - dbMin);
}
-
+ /**
+ * union
+ *
+ * @param value
+ */
public void union(Number value) {
- if(value == null) {
+ if (value == null) {
return;
}
double val = value.doubleValue();
- if(getMin() == null ||
- val < getMin().doubleValue()) {
+ if (getMin() == null || val < getMin().doubleValue()) {
setMin(value);
}
- if(getMax() == null || val >
- getMax().doubleValue()) {
+ if (getMax() == null || val > getMax().doubleValue()) {
setMax(value);
}
}
@@ -160,8 +236,9 @@ public class Region {
* Compares the input bounds min/max against this instance's current min/max.
* If the input.min is less than this.min then this.min will be set to input.min.
* If the input.max is greater than this.max then this.max will be set to input.max
- *
+ *
* The result of a union will always be an equal or larger size region.
+ *
* @param input
*/
public void union(Region input) {
@@ -171,33 +248,19 @@ public class Region {
/**
* The result of an intersect will always be an equal or smaller size region.
+ *
* @param input
*/
public void intersect(Region input) {
- if(getMin().doubleValue() < input.getMin().doubleValue()) {
+ if (getMin().doubleValue() < input.getMin().doubleValue()) {
setMin(input.getMin());
}
- if(getMax().doubleValue() > input.getMax().doubleValue()) {
+ if (getMax().doubleValue() > input.getMax().doubleValue()) {
setMax(input.getMax());
}
}
- /**
- * Tests whether this segment intersects another
- * @param line2Min
- * @param line2Max
- * @return
- */
- public boolean intersects(Number line2Min, Number line2Max) {
-
- // is this line completely within line2?
- if(line2Min.doubleValue() <= getMin().doubleValue() && line2Max.doubleValue() >= getMax().doubleValue()) {
- return true;
- // is line1 partially within line2
- } else return contains(line2Min) || contains(line2Max);
- }
-
public boolean isMinSet() {
return min != null;
}
@@ -206,10 +269,16 @@ public class Region {
return isMinSet() ? min : defaults.min;
}
+ /**
+ * setMin
+ *
+ * @param min
+ * @throws NullPointerException NullPointerException
+ */
public void setMin(Number min) {
cachedLength = null;
- if(min == null) {
- if(defaults == null) {
+ if (min == null) {
+ if (defaults == null) {
throw new NullPointerException(
"Region values cannot be null unless defaults have been set.");
} else {
@@ -228,10 +297,16 @@ public class Region {
return isMaxSet() ? max : defaults.max;
}
+ /**
+ * setMax
+ *
+ * @param max
+ * @throws NullPointerException NullPointerException
+ */
public void setMax(Number max) {
cachedLength = null;
- if(max == null) {
- if(defaults == null) {
+ if (max == null) {
+ if (defaults == null) {
throw new NullPointerException(
"Region values can never be null unless defaults have been set.");
} else {
@@ -243,6 +318,7 @@ public class Region {
}
/**
+ * isDefined
*
* @return True if both min and max values are non-null, false otherwise. Does *not* consider defaults.
*/
diff --git a/androidplot-core/src/main/java/com/androidplot/Series.java b/ohosplot_core/src/main/java/com/ohosplot/Series.java
similarity index 92%
rename from androidplot-core/src/main/java/com/androidplot/Series.java
rename to ohosplot_core/src/main/java/com/ohosplot/Series.java
index a3c26e7b2b9fa4333f7e9cc07e35d7dafdc121dd..0901a3af9bc763dc8618190191b6713763472a5a 100644
--- a/androidplot-core/src/main/java/com/androidplot/Series.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/Series.java
@@ -14,14 +14,16 @@
* limitations under the License.
*/
-package com.androidplot;
+package com.ohosplot;
/**
* Base interface for all Series implementations
+ *
+ * @since 2021-07-23
*/
public interface Series {
-
/**
+ * getTitle
*
* @return The title of this Series.
*/
diff --git a/androidplot-core/src/main/java/com/androidplot/SeriesRegistry.java b/ohosplot_core/src/main/java/com/ohosplot/SeriesRegistry.java
similarity index 62%
rename from androidplot-core/src/main/java/com/androidplot/SeriesRegistry.java
rename to ohosplot_core/src/main/java/com/ohosplot/SeriesRegistry.java
index 7a7b3023c2d84a5a3a329ed69cb206f2b608307b..b4ff908cc271b35ec500d6fdd9beb2cdffa91429 100644
--- a/androidplot-core/src/main/java/com/androidplot/SeriesRegistry.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/SeriesRegistry.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package com.androidplot;
+package com.ohosplot;
-import com.androidplot.ui.Formatter;
-import com.androidplot.ui.SeriesBundle;
+import com.ohosplot.ui.Formatter;
+import com.ohosplot.ui.SeriesBundle;
import java.io.Serializable;
import java.util.ArrayList;
@@ -26,7 +26,12 @@ import java.util.List;
/**
* Manages a list of {@link Series} and their associated {@link Formatter} in the context of a {@link Plot}.
+ *
* @since 0.9.7
+ *
+ * @param
+ * @param
+ * @param
*/
public abstract class SeriesRegistry
,
@@ -37,32 +42,64 @@ public abstract class SeriesRegistry
public List getSeriesAndFormatterList() {
return registry;
}
+
+ /**
+ * getSeriesList
+ *
+ * @return result
+ */
public List getSeriesList() {
List result = new ArrayList<>(registry.size());
- for(SeriesBundle sfPair : registry) {
+ for (SeriesBundle sfPair : registry) {
result.add(sfPair.getSeries());
}
return result;
}
+ /**
+ * size
+ *
+ * @return registry.size()
+ */
public int size() {
return registry.size();
}
+ /**
+ * isEmpty
+ *
+ * @return registry.isEmpty()
+ */
public boolean isEmpty() {
return registry.isEmpty();
}
+ /**
+ * add
+ *
+ * @param series
+ * @param formatter
+ * @return registry.add(newSeriesBundle(series, formatter))
+ * @throws IllegalArgumentException IllegalArgumentException
+ */
public boolean add(SeriesType series, FormatterType formatter) {
- if(series == null || formatter == null) {
+ if (series == null || formatter == null) {
throw new IllegalArgumentException("Neither series nor formatter param may be null.");
}
return registry.add(newSeriesBundle(series, formatter));
}
+ /**
+ * abstract BundleType
+ *
+ * @param series
+ * @param formatter
+ * @return registry.add(newSeriesBundle(series, formatter))
+ */
protected abstract BundleType newSeriesBundle(SeriesType series, FormatterType formatter);
/**
+ * Get SeriesType
*
* @param series
* @return A List of {@link SeriesBundle} instances that reference series.
@@ -70,21 +107,28 @@ public abstract class SeriesRegistry
protected List> get(SeriesType series) {
List> results =
new ArrayList<>();
- for(SeriesBundle thisPair : registry) {
- if(thisPair.getSeries() == series) {
+ for (SeriesBundle thisPair : registry) {
+ if (thisPair.getSeries() == series) {
results.add(thisPair);
}
}
return results;
}
+ /**
+ * remove type
+ *
+ * @param series
+ * @param rendererClass
+ * @return removedItems
+ */
public synchronized List remove(SeriesType series, Class rendererClass) {
ArrayList removedItems = new ArrayList<>();
- for(Iterator it = registry.iterator(); it.hasNext();) {
- BundleType b = it.next();
- if(b.getSeries() == series && b.getFormatter().getRendererClass() == rendererClass) {
+ for (Iterator it = registry.iterator(); it.hasNext(); ) {
+ BundleType bt = it.next();
+ if (bt.getSeries() == series && bt.getFormatter().getRendererClass() == rendererClass) {
it.remove();
- removedItems.add(b);
+ removedItems.add(bt);
}
}
return removedItems;
@@ -92,12 +136,14 @@ public abstract class SeriesRegistry
/**
* Remove all occurrences of series regardless of the associated Renderer.
+ *
* @param series
+ * @return result
*/
public synchronized boolean remove(SeriesType series) {
boolean result = false;
- for(Iterator it = registry.iterator(); it.hasNext();) {
- if(it.next().getSeries() == series) {
+ for (Iterator it = registry.iterator(); it.hasNext(); ) {
+ if (it.next().getSeries() == series) {
it.remove();
result = true;
}
@@ -109,26 +155,38 @@ public abstract class SeriesRegistry
* Remove all series from the plot.
*/
public void clear() {
- for(Iterator it
- = registry.iterator(); it.hasNext();) {
+ for (Iterator it
+ = registry.iterator(); it.hasNext(); ) {
it.next();
it.remove();
}
}
+ /**
+ * getLegendEnabledItems
+ *
+ * @return sfList
+ */
public List> getLegendEnabledItems() {
List> sfList = new ArrayList<>();
- for(SeriesBundle sf : registry) {
- if(sf.getFormatter().isLegendIconEnabled()) {
+ for (SeriesBundle sf : registry) {
+ if (sf.getFormatter().isLegendIconEnabled()) {
sfList.add(sf);
}
}
return sfList;
}
+ /**
+ * contains
+ *
+ * @param series
+ * @param formatterClass
+ * @return false
+ */
public boolean contains(SeriesType series, Class extends FormatterType> formatterClass) {
- for(BundleType b : registry) {
- if(b.getFormatter().getClass() == formatterClass && b.getSeries() == series) {
+ for (BundleType bt : registry) {
+ if (bt.getFormatter().getClass() == formatterClass && bt.getSeries() == series) {
return true;
}
}
diff --git a/androidplot-core/src/main/java/com/androidplot/SimpleLineLabelFormatter.java b/ohosplot_core/src/main/java/com/ohosplot/SimpleLineLabelFormatter.java
similarity index 72%
rename from androidplot-core/src/main/java/com/androidplot/SimpleLineLabelFormatter.java
rename to ohosplot_core/src/main/java/com/ohosplot/SimpleLineLabelFormatter.java
index 6be0200346685c870228fea48f2ab07ca3759755..00051e17291ad8cb7925df3859ca81fe1d995eec 100644
--- a/androidplot-core/src/main/java/com/androidplot/SimpleLineLabelFormatter.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/SimpleLineLabelFormatter.java
@@ -14,37 +14,57 @@
* limitations under the License.
*/
-package com.androidplot;
+package com.ohosplot;
-import android.graphics.Color;
-import android.graphics.Paint;
-import com.androidplot.util.PixelUtils;
+import com.ohosplot.util.PixelUtils;
+
+import ohos.agp.render.Paint;
+import ohos.agp.utils.Color;
/**
* A basic implementation of a {@link LineLabelFormatter}.
+ *
+ * @since 2021-07-23
*/
public class SimpleLineLabelFormatter implements LineLabelFormatter {
-
private static final int DEFAULT_TEXT_SIZE_SP = 12;
private static final int DEFAULT_STROKE_SIZE_DP = 2;
private Paint paint;
+ /**
+ * SimpleLineLabelFormatter
+ */
public SimpleLineLabelFormatter() {
this(new Paint());
getPaint().setColor(Color.WHITE);
- getPaint().setTextSize(PixelUtils.spToPix(DEFAULT_TEXT_SIZE_SP));
- getPaint().setStrokeWidth(PixelUtils.dpToPix(DEFAULT_STROKE_SIZE_DP));
+ getPaint().setTextSize((int) PixelUtils.fpToPix(DEFAULT_TEXT_SIZE_SP));
+ getPaint().setStrokeWidth(PixelUtils.vpToPix(DEFAULT_STROKE_SIZE_DP));
}
+ /**
+ * SimpleLineLabelFormatter
+ *
+ * @param color
+ */
public SimpleLineLabelFormatter(int color) {
this();
- getPaint().setColor(color);
+ getPaint().setColor(new Color(color));
}
+ /**
+ * SimpleLineLabelFormatter
+ *
+ * @param paint
+ */
public SimpleLineLabelFormatter(Paint paint) {
this.paint = paint;
}
+ @Override
+ public Paint getPaint(Number value) {
+ return getPaint();
+ }
+
public Paint getPaint() {
return paint;
}
@@ -52,9 +72,4 @@ public class SimpleLineLabelFormatter implements LineLabelFormatter {
public void setPaint(Paint paint) {
this.paint = paint;
}
-
- @Override
- public Paint getPaint(Number value) {
- return getPaint();
- }
}
diff --git a/ohosplot_core/src/main/java/com/ohosplot/base/NonNull.java b/ohosplot_core/src/main/java/com/ohosplot/base/NonNull.java
new file mode 100644
index 0000000000000000000000000000000000000000..e450ff07d607611998a56928b259fac3ef69c904
--- /dev/null
+++ b/ohosplot_core/src/main/java/com/ohosplot/base/NonNull.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.base;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * NonNull
+ *
+ * @since 2021-07-22
+ */
+@Documented
+@Retention(RetentionPolicy.CLASS)
+@Target({
+ ElementType.METHOD, ElementType.PARAMETER,
+ ElementType.FIELD, ElementType.LOCAL_VARIABLE,
+ ElementType.ANNOTATION_TYPE, ElementType.PACKAGE
+})
+public @interface NonNull {
+}
diff --git a/ohosplot_core/src/main/java/com/ohosplot/bean/BubbleCfgBean.java b/ohosplot_core/src/main/java/com/ohosplot/bean/BubbleCfgBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..88a11bcfafe361921ae684ddcaf89890860bbcf1
--- /dev/null
+++ b/ohosplot_core/src/main/java/com/ohosplot/bean/BubbleCfgBean.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.bean;
+
+/**
+ * BubbleCfgBean
+ *
+ * @since 2021-07-22
+ */
+public class BubbleCfgBean {
+ private int strokePaintColor;
+ private int fillPaintColor;
+
+ /**
+ * BubbleCfgBean
+ *
+ * @param strokePaintColor strokePaintColor
+ * @param fillPaintColor fillPaintColor
+ */
+ public BubbleCfgBean(int strokePaintColor, int fillPaintColor) {
+ this.strokePaintColor = strokePaintColor;
+ this.fillPaintColor = fillPaintColor;
+ }
+
+ public int getStrokePaintColor() {
+ return strokePaintColor;
+ }
+
+ public void setStrokePaintColor(int strokePaintColor) {
+ this.strokePaintColor = strokePaintColor;
+ }
+
+ public int getFillPaintColor() {
+ return fillPaintColor;
+ }
+
+ public void setFillPaintColor(int fillPaintColor) {
+ this.fillPaintColor = fillPaintColor;
+ }
+}
diff --git a/ohosplot_core/src/main/java/com/ohosplot/bean/CandlCfgBean.java b/ohosplot_core/src/main/java/com/ohosplot/bean/CandlCfgBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..ff973d2fcbe9a2d004c2fc8338f9a9fbeed46142
--- /dev/null
+++ b/ohosplot_core/src/main/java/com/ohosplot/bean/CandlCfgBean.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.bean;
+
+/**
+ * CandlCfgBean
+ *
+ * @since 2021-07-22
+ */
+public class CandlCfgBean {
+ private int wickPaintColor;
+ private int upperCapPaintColor;
+ private int lowerCapPaintColor;
+ private int risingBodyStrokePaintColor;
+ private int fallingBodyStrokePaintColor;
+
+ /**
+ * CandlCfgBean
+ *
+ * @param wickPaintColor wickPaintColor
+ * @param upperCapPaintColor upperCapPaintColor
+ * @param lowerCapPaintColor lowerCapPaintColor
+ * @param risingBodyStrokePaintColor risingBodyStrokePaintColor
+ * @param fallingBodyStrokePaintColor fallingBodyStrokePaintColor
+ */
+ public CandlCfgBean(int wickPaintColor, int upperCapPaintColor,
+ int lowerCapPaintColor, int risingBodyStrokePaintColor, int fallingBodyStrokePaintColor) {
+ this.wickPaintColor = wickPaintColor;
+ this.upperCapPaintColor = upperCapPaintColor;
+ this.lowerCapPaintColor = lowerCapPaintColor;
+ this.risingBodyStrokePaintColor = risingBodyStrokePaintColor;
+ this.fallingBodyStrokePaintColor = fallingBodyStrokePaintColor;
+ }
+
+ public int getWickPaintColor() {
+ return wickPaintColor;
+ }
+
+ public void setWickPaintColor(int wickPaintColor) {
+ this.wickPaintColor = wickPaintColor;
+ }
+
+ public int getUpperCapPaintColor() {
+ return upperCapPaintColor;
+ }
+
+ public void setUpperCapPaintColor(int upperCapPaintColor) {
+ this.upperCapPaintColor = upperCapPaintColor;
+ }
+
+ public int getLowerCapPaintColor() {
+ return lowerCapPaintColor;
+ }
+
+ public void setLowerCapPaintColor(int lowerCapPaintColor) {
+ this.lowerCapPaintColor = lowerCapPaintColor;
+ }
+
+ public int getRisingBodyStrokePaintColor() {
+ return risingBodyStrokePaintColor;
+ }
+
+ public void setRisingBodyStrokePaintColor(int risingBodyStrokePaintColor) {
+ this.risingBodyStrokePaintColor = risingBodyStrokePaintColor;
+ }
+
+ public int getFallingBodyStrokePaintColor() {
+ return fallingBodyStrokePaintColor;
+ }
+
+ public void setFallingBodyStrokePaintColor(int fallingBodyStrokePaintColor) {
+ this.fallingBodyStrokePaintColor = fallingBodyStrokePaintColor;
+ }
+}
diff --git a/ohosplot_core/src/main/java/com/ohosplot/bean/PointCfgBean.java b/ohosplot_core/src/main/java/com/ohosplot/bean/PointCfgBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..55090830c6f3d0da0c9159c2053b97dedb9ad7ed
--- /dev/null
+++ b/ohosplot_core/src/main/java/com/ohosplot/bean/PointCfgBean.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.bean;
+
+/**
+ * PointCfgBean
+ *
+ * @since 2021-07-22
+ */
+public class PointCfgBean {
+ private float linePaintStrokeWidth;
+ private int linePaintColor;
+ private int vertexPaintColor;
+ private int fillPaintColor;
+ private float vertexPaintStrokeWidth;
+ private int pointLabelFormatterTextPaintColor;
+
+ /**
+ * PointCfgBean
+ *
+ * @param linePaintStrokeWidth linePaintStrokeWidth
+ * @param linePaintColor linePaintColor
+ * @param vertexPaintColor vertexPaintColor
+ * @param fillPaintColor fillPaintColor
+ * @param vertexPaintStrokeWidth vertexPaintStrokeWidth
+ * @param pointLabelFormatterTextPaintColor pointLabelFormatterTextPaintColor
+ */
+ public PointCfgBean(float linePaintStrokeWidth, int linePaintColor,
+ int vertexPaintColor, int fillPaintColor,
+ float vertexPaintStrokeWidth, int pointLabelFormatterTextPaintColor) {
+ this.linePaintStrokeWidth = linePaintStrokeWidth;
+ this.linePaintColor = linePaintColor;
+ this.vertexPaintColor = vertexPaintColor;
+ this.fillPaintColor = fillPaintColor;
+ this.vertexPaintStrokeWidth = vertexPaintStrokeWidth;
+ this.pointLabelFormatterTextPaintColor = pointLabelFormatterTextPaintColor;
+ }
+
+ public int getPointLabelFormatterTextPaintColor() {
+ return pointLabelFormatterTextPaintColor;
+ }
+
+ public void setPointLabelFormatterTextPaintColor(int pointLabelFormatterTextPaintColor) {
+ this.pointLabelFormatterTextPaintColor = pointLabelFormatterTextPaintColor;
+ }
+
+ public float getLinePaintStrokeWidth() {
+ return linePaintStrokeWidth;
+ }
+
+ public void setLinePaintStrokeWidth(float linePaintStrokeWidth) {
+ this.linePaintStrokeWidth = linePaintStrokeWidth;
+ }
+
+ public int getLinePaintColor() {
+ return linePaintColor;
+ }
+
+ public void setLinePaintColor(int linePaintColor) {
+ this.linePaintColor = linePaintColor;
+ }
+
+ public int getVertexPaintColor() {
+ return vertexPaintColor;
+ }
+
+ public void setVertexPaintColor(int vertexPaintColor) {
+ this.vertexPaintColor = vertexPaintColor;
+ }
+
+ public int getFillPaintColor() {
+ return fillPaintColor;
+ }
+
+ public void setFillPaintColor(int fillPaintColor) {
+ this.fillPaintColor = fillPaintColor;
+ }
+
+ public float getVertexPaintStrokeWidth() {
+ return vertexPaintStrokeWidth;
+ }
+
+ public void setVertexPaintStrokeWidth(float vertexPaintStrokeWidth) {
+ this.vertexPaintStrokeWidth = vertexPaintStrokeWidth;
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/pie/PieChart.java b/ohosplot_core/src/main/java/com/ohosplot/pie/PieChart.java
similarity index 66%
rename from androidplot-core/src/main/java/com/androidplot/pie/PieChart.java
rename to ohosplot_core/src/main/java/com/ohosplot/pie/PieChart.java
index 35e5e41605ffb5cfd5ae676ed6dc29c00514ae5f..3a80fe04aa9ebf39d79f085ead03c136f77167e5 100644
--- a/androidplot-core/src/main/java/com/androidplot/pie/PieChart.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/pie/PieChart.java
@@ -14,23 +14,27 @@
* limitations under the License.
*/
-package com.androidplot.pie;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.util.AttributeSet;
-
-import com.androidplot.*;
-import com.androidplot.ui.*;
-import com.androidplot.util.AttrUtils;
-import com.androidplot.util.PixelUtils;
+package com.ohosplot.pie;
+
+import com.ohosplot.Plot;
+import com.ohosplot.ui.Anchor;
+import com.ohosplot.ui.DynamicTableModel;
+import com.ohosplot.ui.HorizontalPositioning;
+import com.ohosplot.ui.Size;
+import com.ohosplot.ui.SizeMode;
+import com.ohosplot.ui.VerticalPositioning;
+import com.ohosplot.util.Constants;
+import com.ohosplot.util.PixelUtils;
+import ohos.agp.components.AttrSet;
+import ohos.app.Context;
/**
* Basic representation of a Pie Chart that displays a title and pie widget.
+ *
+ * @since 2021-07-22
*/
public class PieChart extends Plot {
-
private static final int DEFAULT_PIE_WIDGET_H_DP = 18;
private static final int DEFAULT_PIE_WIDGET_W_DP = 10;
@@ -49,38 +53,57 @@ public class PieChart extends Plot {
-
private PieChart pieChart;
+ /**
+ * PieLegendWidget
+ *
+ * @param layoutManager layoutManager
+ * @param pieChart pieChart
+ * @param widgetSize widgetSize
+ * @param tableModel tableModel
+ * @param iconSize iconSize
+ */
public PieLegendWidget(LayoutManager layoutManager, PieChart pieChart,
Size widgetSize,
TableModel tableModel,
@@ -26,14 +39,15 @@ public class PieLegendWidget extends LegendWidget {
}
@Override
- protected void drawIcon(@NonNull Canvas canvas, @NonNull RectF iconRect, @NonNull PieLegendItem item) {
+ protected void drawIcon(@NonNull Canvas canvas, @NonNull RectFloat iconRect, @NonNull PieLegendItem item) {
canvas.drawRect(iconRect, item.formatter.getFillPaint());
}
@Override
protected List getLegendItems() {
final List legendItems = new ArrayList<>();
- for(SeriesBundle item : pieChart.getRegistry().getLegendEnabledItems()) {
+ for (SeriesBundle item
+ : pieChart.getRegistry().getLegendEnabledItems()) {
legendItems.add(new PieLegendItem(item.getSeries(), item.getFormatter()));
}
return legendItems;
diff --git a/androidplot-core/src/main/java/com/androidplot/pie/PieRenderer.java b/ohosplot_core/src/main/java/com/ohosplot/pie/PieRenderer.java
similarity index 56%
rename from androidplot-core/src/main/java/com/androidplot/pie/PieRenderer.java
rename to ohosplot_core/src/main/java/com/ohosplot/pie/PieRenderer.java
index db8921dce3aa6268f6e9541934e1add0483c33ff..9954f052b887fa849453f4fdba732e3665aa59a4 100644
--- a/androidplot-core/src/main/java/com/androidplot/pie/PieRenderer.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/pie/PieRenderer.java
@@ -14,21 +14,26 @@
* limitations under the License.
*/
-package com.androidplot.pie;
+package com.ohosplot.pie;
-import android.graphics.*;
+import com.ohosplot.ui.RenderStack;
+import com.ohosplot.ui.SeriesBundle;
+import com.ohosplot.ui.SeriesRenderer;
+import com.ohosplot.util.Constants;
-import com.androidplot.ui.SeriesBundle;
-import com.androidplot.ui.SeriesRenderer;
-import com.androidplot.ui.RenderStack;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.Path;
+import ohos.agp.utils.Point;
+import ohos.agp.utils.RectFloat;
import java.util.List;
/**
* Basic renderer for drawing pie charts.
+ *
+ * @since 2021-07-22
*/
public class PieRenderer extends SeriesRenderer {
-
private static final float FULL_PIE_DEGS = 360f;
private static final float HALF_PIE_DEGS = 180f;
@@ -38,66 +43,100 @@ public class PieRenderer extends SeriesRenderer sfPair : getSeriesAndFormatterList()) {
float lastOffset = offset;
- float sweep = (float) (scale * (values[i]) * extentDegs);
+ float sweep = (float) (scale * (values[ii]) * extentDegs);
offset += sweep;
drawSegment(canvas, rec, sfPair.getSeries(), sfPair.getFormatter(), radius, lastOffset,
sweep);
- i++;
+ ii++;
}
}
- protected void drawSegment(Canvas canvas, RectF bounds, Segment seg, SegmentFormatter f,
- float rad, float startAngle, float sweep) {
+ /**
+ * drawSegment
+ *
+ * @param canvas canvas
+ * @param bounds bounds
+ * @param seg seg
+ * @param segmentFormatter segmentFormatter
+ * @param rad rad
+ * @param startAngle startAngle
+ * @param sweep sweep
+ */
+ protected void drawSegment(Canvas canvas, RectFloat bounds, Segment seg, SegmentFormatter segmentFormatter,
+ float rad, float startAngle, float sweep) {
canvas.save();
- startAngle = startAngle + f.getRadialInset();
- sweep = sweep - (f.getRadialInset() * 2);
+ startAngle = startAngle + segmentFormatter.getRadialInset();
+ sweep = sweep - (segmentFormatter.getRadialInset() * Constants.INT_2);
// midpoint angle between startAngle and endAngle
- final float halfSweepEndAngle = startAngle + (sweep / 2);
+ final float halfSweepEndAngle = startAngle + (sweep / Constants.INT_2);
- PointF translated = calculateLineEnd(
- bounds.centerX(), bounds.centerY(), f.getOffset(), halfSweepEndAngle);
+ Point translated = calculateLineEnd(
+ bounds.getCenter().getPointX(), bounds.getCenter().getPointY(),
+ segmentFormatter.getOffset(), halfSweepEndAngle);
- final float cx = translated.x;
- final float cy = translated.y;
+ final float cx = translated.getPointX();
+ final float cy = translated.getPointY();
float donutSizePx;
switch (donutMode) {
@@ -111,18 +150,18 @@ public class PieRenderer extends SeriesRenderer Float.MIN_VALUE) {
// vertices of the first radial:
- PointF r1Outer = calculateLineEnd(cx, cy, outerRad, startAngle);
- PointF r1Inner = calculateLineEnd(cx, cy, innerRad, startAngle);
+ Point r1Outer = calculateLineEnd(cx, cy, outerRad, startAngle);
+ Point r1Inner = calculateLineEnd(cx, cy, innerRad, startAngle);
// vertices of the second radial:
- PointF r2Outer = calculateLineEnd(cx, cy, outerRad, startAngle + sweep);
- PointF r2Inner = calculateLineEnd(cx, cy, innerRad, startAngle + sweep);
+ Point r2Outer = calculateLineEnd(cx, cy, outerRad, startAngle + sweep);
+ Point r2Inner = calculateLineEnd(cx, cy, innerRad, startAngle + sweep);
Path clip = new Path();
@@ -131,147 +170,174 @@ public class PieRenderer extends SeriesRenderer> seriesList = getSeriesAndFormatterList();
double[] result = new double[seriesList.size()];
- int i = 0;
+ int ii = 0;
for (SeriesBundle sfPair : seriesList) {
- result[i] = sfPair.getSeries().getValue().doubleValue();
- i++;
+ result[ii] = sfPair.getSeries().getValue().doubleValue();
+ ii++;
}
return result;
}
- protected PointF calculateLineEnd(float x, float y, float rad, float deg) {
- return calculateLineEnd(new PointF(x, y), rad, deg);
+ /**
+ * calculateLineEnd
+ *
+ * @param xx xx
+ * @param yy yy
+ * @param rad rad
+ * @param deg deg
+ * @return Point
+ */
+ protected Point calculateLineEnd(float xx, float yy, float rad, float deg) {
+ return calculateLineEnd(new Point(xx, yy), rad, deg);
}
- protected PointF calculateLineEnd(PointF origin, float rad, float deg) {
-
+ /**
+ * calculateLineEnd
+ *
+ * @param origin origin
+ * @param rad rad
+ * @param deg deg
+ * @return Point
+ */
+ protected Point calculateLineEnd(Point origin, float rad, float deg) {
double radians = deg * Math.PI / HALF_PIE_DEGS;
- double x = rad * Math.cos(radians);
- double y = rad * Math.sin(radians);
+ double xx = rad * Math.cos(radians);
+ double yy = rad * Math.sin(radians);
// convert to screen space:
- return new PointF(origin.x + (float) x, origin.y + (float) y);
+ return new Point(origin.getPointX() + (float) xx, origin.getPointY() + (float) yy);
}
/**
* Set the size of the pie's empty inner space. May be specified as either pixels or as a percentage.
* If using {@link DonutMode#PIXELS}, the best practice is to specify values in dp using
- * {@link com.androidplot.util.PixelUtils#dpToPix(float)}.
- *
+ * {@link com.ohosplot.util.PixelUtils#vpToPix(float)}.
+ *
* If using {@link DonutMode#PERCENT} the value must be within the range 0 - 1. The value being
* set corresponds to the size of the donut radius relative to the pie's total radius.
- * @param size
- * @param mode
+ *
+ * @param size size
+ * @param mode mode
*/
public void setDonutSize(float size, DonutMode mode) {
switch (mode) {
case PERCENT:
if (size < 0 || size > 1) {
- throw new IllegalArgumentException(
- "Size parameter must be between 0 and 1 when operating in PERCENT mode.");
+ return;
}
break;
case PIXELS:
break;
default:
- throw new UnsupportedOperationException("Not yet implemented.");
+ return;
}
donutMode = mode;
donutSize = size;
@@ -282,19 +348,20 @@ public class PieRenderer extends SeriesRenderer> seriesList = getSeriesAndFormatterList();
- int i = 0;
+ int ii = 0;
double[] values = getValues();
double scale = calculateScale(values);
float offset = degsToScreenDegs(startDegs);
for (SeriesBundle sfPair : seriesList) {
float lastOffset = offset;
- float sweep = (float) (scale * (values[i]) * extentDegs);
+ float sweep = (float) (scale * (values[ii]) * extentDegs);
offset += sweep;
offset = offset % FULL_PIE_DEGS;
final double dist = signedDistance(offset, angle);
double endDist = signedDistance(offset, lastOffset);
- if(endDist < 0) {
+ if (endDist < 0) {
// segment accounts for more than 50% of the pie and wrapped around
// need to correct:
endDist = FULL_PIE_DEGS + endDist;
}
- if(dist > 0 && dist <= endDist) {
+ if (dist > 0 && dist <= endDist) {
return sfPair.getSeries();
}
- i++;
+ ii++;
}
return null;
}
@@ -331,13 +398,14 @@ public class PieRenderer extends SeriesRenderer= 369 will be converted back into the range of 0 - 359.999...
+ *
* @param degs
- * @return
+ * @return float
*/
protected static float degsToScreenDegs(float degs) {
degs = degs % FULL_PIE_DEGS;
- if (degs > 0) {
+ if (degs > 0) {
return FULL_PIE_DEGS - degs;
} else {
return degs;
@@ -346,35 +414,39 @@ public class PieRenderer extends SeriesRenderer HALF_PIE_DEGS ? FULL_PIE_DEGS - d : d;
+ double ddDouble = Math.abs(angle1 - angle2) % FULL_PIE_DEGS;
+ double rrDouble = ddDouble > HALF_PIE_DEGS ? FULL_PIE_DEGS - ddDouble : ddDouble;
- //calculate sign
+ // calculate sign
int sign = (angle1 - angle2 >= 0 && angle1 - angle2 <= HALF_PIE_DEGS)
- || (angle1 - angle2 <= -HALF_PIE_DEGS && angle1 - angle2 >= -FULL_PIE_DEGS) ? 1 : -1;
- r *= sign;
- return r;
+ || (angle1 - angle2 <= -HALF_PIE_DEGS && angle1 - angle2 >= -FULL_PIE_DEGS) ? 1
+ : Constants.INT_F1;
+ rrDouble *= sign;
+ return rrDouble;
}
/**
* Throws an IllegalArgumentException if the input value is outside of the range of 0.0 to 360.0
- * @param degs
+ *
+ * @param degs degs
*/
protected static void validateInputDegs(float degs) {
- if(degs < 0 || degs > FULL_PIE_DEGS) {
- throw new IllegalArgumentException("Degrees values must be between 0.0 and 360.");
+ if (degs < 0 || degs > FULL_PIE_DEGS) {
+ return;
}
}
/**
* Set the starting point in degrees from which series will be drawn in order.
* The input value must be within the range 0 - 360.
- * @param degs
+ *
+ * @param degs degs
*/
public void setStartDegs(float degs) {
validateInputDegs(degs);
@@ -389,7 +461,8 @@ public class PieRenderer extends SeriesRenderer renderStack;
+ /**
+ * PieWidget
+ *
+ * @param layoutManager layoutManager
+ * @param pieChart pieChart
+ * @param metrics metrics
+ */
public PieWidget(LayoutManager layoutManager, PieChart pieChart, Size metrics) {
super(layoutManager, metrics);
this.pieChart = pieChart;
@@ -37,10 +47,10 @@ public class PieWidget extends Widget {
}
@Override
- protected void doOnDraw(Canvas canvas, RectF widgetRect) {
+ protected void doOnDraw(Canvas canvas, RectFloat widgetRect) {
renderStack.sync();
- for(RenderStack.StackElement thisElement : renderStack.getElements()) {
- if(thisElement.isEnabled()) {
+ for (RenderStack.StackElement thisElement : renderStack.getElements()) {
+ if (thisElement.isEnabled()) {
pieChart.getRenderer(thisElement.get().getFormatter().getRendererClass()).
render(canvas, widgetRect, thisElement.get(), renderStack);
}
diff --git a/androidplot-core/src/main/java/com/androidplot/pie/Segment.java b/ohosplot_core/src/main/java/com/ohosplot/pie/Segment.java
similarity index 87%
rename from androidplot-core/src/main/java/com/androidplot/pie/Segment.java
rename to ohosplot_core/src/main/java/com/ohosplot/pie/Segment.java
index 28a146da7870dba070ae3acf7d35dc3068afb8a6..c5fc0db0a2c37dbe3e1b3c6a5f575cf290f1f342 100644
--- a/androidplot-core/src/main/java/com/androidplot/pie/Segment.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/pie/Segment.java
@@ -14,12 +14,14 @@
* limitations under the License.
*/
-package com.androidplot.pie;
+package com.ohosplot.pie;
-import com.androidplot.Series;
+import com.ohosplot.Series;
/**
* An implementation of Series representing a segment in a pie chart.
+ *
+ * @since 2021-07-22
*/
public class Segment implements Series {
@@ -27,6 +29,12 @@ public class Segment implements Series {
private Number value;
+ /**
+ * Segment
+ *
+ * @param title title
+ * @param value value
+ */
public Segment(String title, Number value) {
this.title = title;
this.setValue(value);
diff --git a/androidplot-core/src/main/java/com/androidplot/pie/SegmentBundle.java b/ohosplot_core/src/main/java/com/ohosplot/pie/SegmentBundle.java
similarity index 62%
rename from androidplot-core/src/main/java/com/androidplot/pie/SegmentBundle.java
rename to ohosplot_core/src/main/java/com/ohosplot/pie/SegmentBundle.java
index 465fd69b3a5f91043910225b3bb900025a838acf..0b1cbccc73aef5ec8ac37044b0de4136eeba06f5 100644
--- a/androidplot-core/src/main/java/com/androidplot/pie/SegmentBundle.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/pie/SegmentBundle.java
@@ -1,13 +1,20 @@
-package com.androidplot.pie;
+package com.ohosplot.pie;
-import com.androidplot.ui.*;
+import com.ohosplot.ui.SeriesBundle;
/**
* Manages the association between a given {@link Segment} and the {@link SegmentFormatter} that
* will be used to render it.
+ *
+ * @since 2021-07-22
*/
public class SegmentBundle extends SeriesBundle {
-
+ /**
+ * SegmentBundle
+ *
+ * @param series series
+ * @param formatter formatter
+ */
public SegmentBundle(Segment series, SegmentFormatter formatter) {
super(series, formatter);
}
diff --git a/androidplot-core/src/main/java/com/androidplot/pie/SegmentFormatter.java b/ohosplot_core/src/main/java/com/ohosplot/pie/SegmentFormatter.java
similarity index 67%
rename from androidplot-core/src/main/java/com/androidplot/pie/SegmentFormatter.java
rename to ohosplot_core/src/main/java/com/ohosplot/pie/SegmentFormatter.java
index 04368a017a5d5bb34adac34c03417e0299822262..e12ccf059df8d12f81bc2d8b7884d50f2adb9b31 100644
--- a/androidplot-core/src/main/java/com/androidplot/pie/SegmentFormatter.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/pie/SegmentFormatter.java
@@ -14,22 +14,30 @@
* limitations under the License.
*/
-package com.androidplot.pie;
+package com.ohosplot.pie;
-import android.content.*;
-import android.graphics.Color;
-import android.graphics.Paint;
-import com.androidplot.ui.SeriesRenderer;
-import com.androidplot.ui.Formatter;
+import com.ohosplot.ui.Formatter;
+import com.ohosplot.ui.SeriesRenderer;
+import com.ohosplot.util.Constants;
+import com.ohosplot.util.PixelUtils;
-public class SegmentFormatter extends Formatter {
+import ohos.agp.render.Paint;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.TextAlignment;
+import ohos.app.Context;
- private static final int DEFAULT_FILL_COLOR = Color.TRANSPARENT;
- private static final int DEFAULT_EDGE_COLOR = Color.BLACK;
- private static final int DEFAULT_LABEL_COLOR = Color.WHITE;
+/**
+ * SegmentFormatter
+ *
+ * @since 2021-07-22
+ */
+public class SegmentFormatter extends Formatter {
+ private static final Color DEFAULT_FILL_COLOR = Color.TRANSPARENT;
+ private static final Color DEFAULT_EDGE_COLOR = Color.BLACK;
+ private static final Color DEFAULT_LABEL_COLOR = Color.WHITE;
private static final float DEFAULT_EDGE_THICKNESS = 3;
private static final float DEFAULT_LABEL_MARKER_THICKNESS = 3;
- private static final float DEFAULT_LABEL_FONT_SIZE = 18;
+ private static final int DEFAULT_LABEL_FONT_SIZE = 18;
private Paint innerEdgePaint;
private Paint outerEdgePaint;
@@ -46,21 +54,22 @@ public class SegmentFormatter extends Formatter {
{
setFillPaint(new Paint());
+
// outer edge:
setOuterEdgePaint(new Paint());
- getOuterEdgePaint().setStyle(Paint.Style.STROKE);
+ getOuterEdgePaint().setStyle(Paint.Style.STROKE_STYLE);
getOuterEdgePaint().setStrokeWidth(DEFAULT_EDGE_THICKNESS);
getOuterEdgePaint().setAntiAlias(true);
// inner edge:
setInnerEdgePaint(new Paint());
- getInnerEdgePaint().setStyle(Paint.Style.STROKE);
+ getInnerEdgePaint().setStyle(Paint.Style.STROKE_STYLE);
getInnerEdgePaint().setStrokeWidth(DEFAULT_EDGE_THICKNESS);
getInnerEdgePaint().setAntiAlias(true);
// radial edge:
setRadialEdgePaint(new Paint());
- getRadialEdgePaint().setStyle(Paint.Style.STROKE);
+ getRadialEdgePaint().setStyle(Paint.Style.STROKE_STYLE);
getRadialEdgePaint().setStrokeWidth(DEFAULT_EDGE_THICKNESS);
getRadialEdgePaint().setAntiAlias(true);
@@ -69,7 +78,7 @@ public class SegmentFormatter extends Formatter {
getLabelPaint().setColor(DEFAULT_LABEL_COLOR);
getLabelPaint().setTextSize(DEFAULT_LABEL_FONT_SIZE);
getLabelPaint().setAntiAlias(true);
- getLabelPaint().setTextAlign(Paint.Align.CENTER);
+ getLabelPaint().setTextAlign(TextAlignment.CENTER);
// label marker paint:
setLabelMarkerPaint(new Paint());
@@ -77,44 +86,73 @@ public class SegmentFormatter extends Formatter {
getLabelMarkerPaint().setStrokeWidth(DEFAULT_LABEL_MARKER_THICKNESS);
}
+ /**
+ * SegmentFormatter
+ *
+ * @param fillColor fillColor
+ */
public SegmentFormatter(Integer fillColor) {
- if(fillColor != null) {
- getFillPaint().setColor(fillColor);
+ if (fillColor != null) {
+ getFillPaint().setColor(new Color(fillColor));
} else {
getFillPaint().setColor(DEFAULT_FILL_COLOR);
}
}
- public SegmentFormatter(Context context, int xmlCfgId) {
- configure(context, xmlCfgId);
+ /**
+ * SegmentFormatter
+ *
+ * @param context context
+ * @param colorIntNum colorIntNum
+ */
+ public SegmentFormatter(Context context, int colorIntNum) {
+ configure(context, colorIntNum);
+ fillPaint.setColor(new Color(colorIntNum));
+ fillPaint.setAntiAlias(true);
+ labelPaint.setTextSize((int) PixelUtils.fpToPix(Constants.INT_20));
+ labelPaint.setAntiAlias(true);
}
- public SegmentFormatter(Integer fillColor, Integer borderColor) {
+ /**
+ * SegmentFormatter
+ *
+ * @param fillColor fillColor
+ * @param borderColor borderColor
+ */
+ public SegmentFormatter(int fillColor, int borderColor) {
this(fillColor);
- getInnerEdgePaint().setColor(borderColor);
- getOuterEdgePaint().setColor(borderColor);
- getRadialEdgePaint().setColor(borderColor);
+ getInnerEdgePaint().setColor(new Color(borderColor));
+ getOuterEdgePaint().setColor(new Color(borderColor));
+ getRadialEdgePaint().setColor(new Color(borderColor));
}
- public SegmentFormatter(Integer fillColor, Integer outerEdgeColor,
- Integer innerEdgeColor, Integer radialEdgeColor) {
+ /**
+ * SegmentFormatter
+ *
+ * @param fillColor fillColor
+ * @param outerEdgeColor outerEdgeColor
+ * @param innerEdgeColor innerEdgeColor
+ * @param radialEdgeColor radialEdgeColor
+ */
+ public SegmentFormatter(int fillColor, int outerEdgeColor,
+ int innerEdgeColor, int radialEdgeColor) {
this(fillColor);
- if(getOuterEdgePaint() != null) {
- getOuterEdgePaint().setColor(outerEdgeColor);
+ if (getOuterEdgePaint() != null) {
+ getOuterEdgePaint().setColor(new Color(outerEdgeColor));
} else {
outerEdgePaint = new Paint();
getOuterEdgePaint().setColor(DEFAULT_EDGE_COLOR);
}
if (getInnerEdgePaint() != null) {
- getInnerEdgePaint().setColor(innerEdgeColor);
+ getInnerEdgePaint().setColor(new Color(innerEdgeColor));
} else {
outerEdgePaint = new Paint();
getInnerEdgePaint().setColor(DEFAULT_EDGE_COLOR);
}
if (getRadialEdgePaint() != null) {
- getRadialEdgePaint().setColor(radialEdgeColor);
+ getRadialEdgePaint().setColor(new Color(radialEdgeColor));
} else {
radialEdgePaint = new Paint();
getRadialEdgePaint().setColor(DEFAULT_EDGE_COLOR);
@@ -186,7 +224,8 @@ public class SegmentFormatter extends Formatter {
/**
* Set an offset relative to the center of the pie chart at which this segment should be drawn;
* generally used to highlight specific segments.
- * @param offset
+ *
+ * @param offset offset
*/
public void setOffset(float offset) {
this.offset = offset;
@@ -199,7 +238,8 @@ public class SegmentFormatter extends Formatter {
/**
* Set an inset in degrees for the radial edges of this segment.
* generally used to highlight specific segments.
- * @param radialInset
+ *
+ * @param radialInset radialInset
*/
public void setRadialInset(float radialInset) {
this.radialInset = radialInset;
diff --git a/androidplot-core/src/main/java/com/androidplot/pie/SegmentRegistry.java b/ohosplot_core/src/main/java/com/ohosplot/pie/SegmentRegistry.java
similarity index 79%
rename from androidplot-core/src/main/java/com/androidplot/pie/SegmentRegistry.java
rename to ohosplot_core/src/main/java/com/ohosplot/pie/SegmentRegistry.java
index 1cbf905fdfe46b17bc80b76a86a8e61a0b0199b2..ad1215faf4cb7efbe2027ee6ed516aa7821a6a05 100644
--- a/androidplot-core/src/main/java/com/androidplot/pie/SegmentRegistry.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/pie/SegmentRegistry.java
@@ -1,12 +1,13 @@
-package com.androidplot.pie;
+package com.ohosplot.pie;
-import com.androidplot.*;
+import com.ohosplot.SeriesRegistry;
/**
* SeriesRegistry implementation to be used in a {@link PieChart}.
+ *
+ * @since 2021-07-22
*/
public class SegmentRegistry extends SeriesRegistry {
-
@Override
protected SegmentBundle newSeriesBundle(Segment series, SegmentFormatter formatter) {
return new SegmentBundle(series, formatter);
diff --git a/ohosplot_core/src/main/java/com/ohosplot/style/ApDefactoDarkStyleBean.java b/ohosplot_core/src/main/java/com/ohosplot/style/ApDefactoDarkStyleBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..8cbbff850178a3dffe68c37f077169c056b38ce6
--- /dev/null
+++ b/ohosplot_core/src/main/java/com/ohosplot/style/ApDefactoDarkStyleBean.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.style;
+
+import com.ohosplot.ResourceTable;
+
+import ohos.agp.utils.Color;
+import ohos.app.Context;
+import ohos.global.resource.NotExistException;
+import ohos.global.resource.ResourceManager;
+import ohos.global.resource.WrongTypeException;
+
+import java.io.IOException;
+
+/**
+ * ApDefactoDarkStyleBean
+ *
+ * @since 2021-07-22
+ */
+public class ApDefactoDarkStyleBean extends ApDefactoStyleBean {
+ /**
+ * ApDefactoDarkStyleBean
+ *
+ * @param context context
+ */
+ public ApDefactoDarkStyleBean(Context context) {
+ super(context);
+ ResourceManager resManager = context.getResourceManager();
+ try {
+ Color apBlack = new Color(resManager.getElement(ResourceTable.Color_ap_black).getColor());
+ Color apCharcoal = new Color(resManager.getElement(ResourceTable.Color_ap_charcoal).getColor());
+ Color offWhite = new Color(resManager.getElement(ResourceTable.Color_off_white).getColor());
+ Color apWhite = new Color(resManager.getElement(ResourceTable.Color_ap_white).getColor());
+ getStyleMap().put("backgroundColor",apBlack);
+ getStyleMap().put("graphBackgroundColor",apBlack);
+ getStyleMap().put("gridBackgroundColor",apCharcoal);
+ getStyleMap().put("domainLineColor",offWhite);
+ getStyleMap().put("rangeLineColor",offWhite);
+ getStyleMap().put("domainOriginLineColor",offWhite);
+ getStyleMap().put("rangeOriginLineColor",offWhite);
+ getStyleMap().put("lineLabelTextColorTop",offWhite);
+ getStyleMap().put("lineLabelTextColorBottom",offWhite);
+ getStyleMap().put("lineLabelTextColorLeft",offWhite);
+ getStyleMap().put("lineLabelTextColorRight",offWhite);
+ getStyleMap().put("titleTextColor",apWhite);
+ getStyleMap().put("domainTitleTextColor",apWhite);
+ getStyleMap().put("rangeTitleTextColor",apWhite);
+ getStyleMap().put("legendTextColor",apWhite);
+ } catch (NotExistException | WrongTypeException | IOException e) {
+ return;
+ }
+ }
+}
diff --git a/ohosplot_core/src/main/java/com/ohosplot/style/ApDefactoLightStyleBean.java b/ohosplot_core/src/main/java/com/ohosplot/style/ApDefactoLightStyleBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..825116125520e057a5c6619e8a2a7786213165a3
--- /dev/null
+++ b/ohosplot_core/src/main/java/com/ohosplot/style/ApDefactoLightStyleBean.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.style;
+
+import com.ohosplot.ResourceTable;
+
+import ohos.agp.utils.Color;
+import ohos.app.Context;
+import ohos.global.resource.NotExistException;
+import ohos.global.resource.ResourceManager;
+import ohos.global.resource.WrongTypeException;
+
+import java.io.IOException;
+
+/**
+ * ApDefactoLightStyleBean
+ *
+ * @since 2021-07-22
+ */
+public class ApDefactoLightStyleBean extends ApDefactoStyleBean {
+ /**
+ * ApDefactoLightStyleBean
+ *
+ * @param context context
+ */
+ public ApDefactoLightStyleBean(Context context) {
+ super(context);
+ ResourceManager resManager = context.getResourceManager();
+ try {
+ Color apBlack = new Color(resManager.getElement(ResourceTable.Color_ap_black).getColor());
+ Color apCharcoal = new Color(resManager.getElement(ResourceTable.Color_ap_charcoal).getColor());
+ Color offWhite = new Color(resManager.getElement(ResourceTable.Color_off_white).getColor());
+ Color apGray = new Color(resManager.getElement(ResourceTable.Color_ap_gray).getColor());
+ Color apWhite = new Color(resManager.getElement(ResourceTable.Color_ap_white).getColor());
+ getStyleMap().put("backgroundColor",offWhite);
+ getStyleMap().put("graphBackgroundColor",offWhite);
+ getStyleMap().put("gridBackgroundColor",apWhite);
+ getStyleMap().put("domainLineColor",apGray);
+ getStyleMap().put("rangeLineColor",apGray);
+ getStyleMap().put("domainOriginLineColor",apCharcoal);
+ getStyleMap().put("rangeOriginLineColor",apCharcoal);
+ getStyleMap().put("lineLabelTextColorTop",apCharcoal);
+ getStyleMap().put("lineLabelTextColorBottom",apCharcoal);
+ getStyleMap().put("lineLabelTextColorLeft",apCharcoal);
+ getStyleMap().put("lineLabelTextColorRight",apCharcoal);
+ getStyleMap().put("titleTextColor",apBlack);
+ getStyleMap().put("domainTitleTextColor",apBlack);
+ getStyleMap().put("rangeTitleTextColor",apBlack);
+ getStyleMap().put("legendTextColor",apBlack);
+ } catch (IOException | NotExistException | WrongTypeException e) {
+ return;
+ }
+ }
+}
diff --git a/ohosplot_core/src/main/java/com/ohosplot/style/ApDefactoStyleBean.java b/ohosplot_core/src/main/java/com/ohosplot/style/ApDefactoStyleBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..d28383b660d19f9219ffc7dc6da50cb2823d4e7c
--- /dev/null
+++ b/ohosplot_core/src/main/java/com/ohosplot/style/ApDefactoStyleBean.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.style;
+
+import com.ohosplot.ResourceTable;
+
+import ohos.agp.utils.Color;
+import ohos.app.Context;
+import ohos.global.resource.NotExistException;
+import ohos.global.resource.ResourceManager;
+import ohos.global.resource.WrongTypeException;
+
+import java.io.IOException;
+
+/**
+ * ApDefactoStyleBean
+ *
+ * @since 2021-07-22
+ */
+public class ApDefactoStyleBean extends BaseStyleBean {
+ /**
+ * ApDefactoStyleBean
+ *
+ * @param context context
+ */
+ public ApDefactoStyleBean(Context context) {
+ super(context);
+ ResourceManager resManager = context.getResourceManager();
+ try {
+ getStyleMap().put("titleTextSize",resManager.getElement(
+ ResourceTable.Float_titleTextSize).getFloat());
+ getStyleMap().put("rangeTitleTextSize",resManager.getElement(
+ ResourceTable.Float_rangeTitleTextSize).getFloat());
+ getStyleMap().put("domainTitleTextSize",resManager.getElement(
+ ResourceTable.Float_domainTitleTextSize).getFloat());
+ getStyleMap().put("graphMarginTop",resManager.getElement(
+ ResourceTable.Float_graphMarginTop).getFloat());
+ getStyleMap().put("graphMarginBottom",resManager.getElement(
+ ResourceTable.Float_graphMarginBottom).getFloat());
+ getStyleMap().put("graphMarginLeft",resManager.getElement(
+ ResourceTable.Float_graphMarginLeft).getFloat());
+ getStyleMap().put("graphMarginRight",resManager.getElement(
+ ResourceTable.Float_graphMarginRight).getFloat());
+ getStyleMap().put("domainLineThickness",resManager.getElement(
+ ResourceTable.Float_domainLineThickness).getFloat());
+ getStyleMap().put("rangeLineThickness",resManager.getElement(
+ ResourceTable.Float_rangeLineThickness).getFloat());
+ getStyleMap().put("domainOriginLineThickness",resManager.getElement(
+ ResourceTable.Float_domainOriginLineThickness).getFloat());
+ getStyleMap().put("rangeOriginLineThickness",resManager.getElement(
+ ResourceTable.Float_rangeOriginLineThickness).getFloat());
+ getStyleMap().put("legendTextSize",resManager.getElement(ResourceTable.Float_legendTextSize).getFloat());
+ getStyleMap().put("legendIconHeight",resManager.getElement(
+ ResourceTable.Float_legendIconHeight).getFloat());
+ getStyleMap().put("legendIconWidth",resManager.getElement(ResourceTable.Float_legendIconWidth).getFloat());
+ getStyleMap().put("legendHeight",resManager.getElement(ResourceTable.Float_legendHeight).getFloat());
+ getStyleMap().put("gridInsetTop",resManager.getElement(ResourceTable.Float_gridInsetTop).getFloat());
+ getStyleMap().put("gridInsetLeft",resManager.getElement(ResourceTable.Float_gridInsetLeft).getFloat());
+ getStyleMap().put("gridInsetBottom",resManager.getElement(ResourceTable.Float_gridInsetBottom).getFloat());
+ getStyleMap().put("gridInsetRight",resManager.getElement(
+ ResourceTable.Float_gridInsetRight).getFloat());
+ getStyleMap().put("lineLabelInsetTop",resManager.getElement(
+ ResourceTable.Float_lineLabelInsetTop).getFloat());
+ getStyleMap().put("lineLabelInsetBottom",resManager.getElement(
+ ResourceTable.Float_lineLabelInsetBottom).getFloat());
+ getStyleMap().put("lineLabelInsetLeft",resManager.getElement(
+ ResourceTable.Float_lineLabelInsetLeft).getFloat());
+ getStyleMap().put("lineLabelInsetRight",resManager.getElement(
+ ResourceTable.Float_lineLabelInsetRight).getFloat());
+ getStyleMap().put("lineLabelTextSizeTop",resManager.getElement(
+ ResourceTable.Float_lineLabelTextSizeTop).getFloat());
+ getStyleMap().put("lineLabelTextSizeBottom",resManager.getElement(
+ ResourceTable.Float_lineLabelTextSizeBottom).getFloat());
+ getStyleMap().put("lineLabelTextSizeLeft",resManager.getElement(
+ ResourceTable.Float_lineLabelTextSizeLeft).getFloat());
+ getStyleMap().put("lineLabelTextSizeRight",resManager.getElement(
+ ResourceTable.Float_lineLabelTextSizeRight).getFloat());
+ getStyleMap().put("lineExtensionLeft",resManager.getElement(
+ ResourceTable.Float_lineExtensionLeft).getFloat());
+ getStyleMap().put("lineExtensionBottom",resManager.getElement(
+ ResourceTable.Float_lineExtensionBottom).getFloat());
+ getStyleMap().put("lineLabelRotationBottom",resManager.getElement(
+ ResourceTable.Integer_lineLabelRotationBottom).getInteger());
+ getStyleMap().put("lineLabelRotationTop",resManager.getElement(
+ ResourceTable.Integer_lineLabelRotationTop).getInteger());
+ getStyleMap().put("legendAnchor",getAnchor(
+ resManager.getElement(ResourceTable.String_legendAnchor).getString()));
+ getStyleMap().put("borderColor",new Color(
+ resManager.getElement(ResourceTable.Color_ap_transparent).getColor()));
+ getStyleMap().put("lineLabels",getLineLabels(
+ resManager.getElement(ResourceTable.String_lineLabels).getString()));
+ getStyleMap().put("lineLabelAlignLeft",getAlign(
+ resManager.getElement(ResourceTable.String_lineLabelAlignLeft).getString()));
+ getStyleMap().put("lineLabelAlignRight",getAlign(
+ resManager.getElement(ResourceTable.String_lineLabelAlignRight).getString()));
+ getStyleMap().put("lineLabelAlignTop",getAlign(
+ resManager.getElement(ResourceTable.String_lineLabelAlignTop).getString()));
+ getStyleMap().put("lineLabelAlignBottom",getAlign(
+ resManager.getElement(ResourceTable.String_lineLabelAlignBottom).getString()));
+ } catch (IOException | NotExistException | WrongTypeException e) {
+ return;
+ }
+ }
+}
diff --git a/ohosplot_core/src/main/java/com/ohosplot/style/BaseStyleBean.java b/ohosplot_core/src/main/java/com/ohosplot/style/BaseStyleBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..70096d0f7bbf50e6037e4e898774720b5736d543
--- /dev/null
+++ b/ohosplot_core/src/main/java/com/ohosplot/style/BaseStyleBean.java
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.style;
+
+import com.ohosplot.ui.Anchor;
+import com.ohosplot.ui.HorizontalPositioning;
+import com.ohosplot.ui.SizeMode;
+import com.ohosplot.ui.VerticalPositioning;
+import com.ohosplot.util.Constants;
+
+import ohos.agp.utils.TextAlignment;
+import ohos.app.Context;
+
+import java.util.HashMap;
+
+/**
+ * BaseStyleBean
+ *
+ * @since 2021-07-22
+ */
+public class BaseStyleBean {
+ /**
+ * AP_DEFACTO_STYLE
+ */
+ public static final String AP_DEFACTO_STYLE = "APDefacto";
+ /**
+ * AP_DEFACTO_DARK_STYLE
+ */
+ public static final String AP_DEFACTO_DARK_STYLE = "APDefactoDark";
+ /**
+ * AP_DEFACTO_LIGHT_STYLE
+ */
+ public static final String AP_DEFACTO_LIGHT_STYLE = "APDefactoLight";
+ /**
+ * FULL_SCREEN_GRAPH_STYLE
+ */
+ public static final String FULL_SCREEN_GRAPH_STYLE = "FullScreenGraph";
+ /**
+ * MINIMALIST_STYLE
+ */
+ public static final String MINIMALIST_STYLE = "Minimalist";
+ /**
+ * MINIMALIST_DARK_STYLE
+ */
+ public static final String MINIMALIST_DARK_STYLE = "MinimalistDark";
+ /**
+ * MINIMALIST_LIGHT_STYLE
+ */
+ public static final String MINIMALIST_LIGHT_STYLE = "MinimalistLight";
+
+ private HashMap styleMap = new HashMap<>();
+ private Context mContext;
+
+ /**
+ * BaseStyleBean
+ *
+ * @param context context
+ */
+ public BaseStyleBean(Context context) {
+ mContext = context;
+ }
+
+ public Context getContext() {
+ return mContext;
+ }
+
+ public HashMap getStyleMap() {
+ return styleMap;
+ }
+
+ /**
+ * getAnchor
+ *
+ * @param anchor anchor
+ * @return Anchor
+ */
+ public static Anchor getAnchor(String anchor) {
+ switch (anchor) {
+ case "top_middle":
+ return Anchor.TOP_MIDDLE;
+ case "left_top":
+ return Anchor.LEFT_TOP;
+ case "left_middle":
+ return Anchor.LEFT_MIDDLE;
+ case "left_bottom":
+ return Anchor.LEFT_BOTTOM;
+ case "right_top":
+ return Anchor.RIGHT_TOP;
+ case "right_middle":
+ return Anchor.RIGHT_MIDDLE;
+ case "right_bottom":
+ return Anchor.RIGHT_BOTTOM;
+ case "bottom_middle":
+ return Anchor.BOTTOM_MIDDLE;
+ case "center":
+ return Anchor.CENTER;
+ default:
+ return Anchor.RIGHT_BOTTOM;
+ }
+ }
+
+ /**
+ * getLineLabels
+ *
+ * @param labels labels
+ * @return int
+ */
+ public static int getLineLabels(String labels) {
+ String[] strings = labels.replace(" ","").split("\\|");
+ int labelNum = 0;
+ for (String string : strings) {
+ switch (string) {
+ case "left":
+ labelNum = labelNum + 1;
+ break;
+ case "right":
+ labelNum = labelNum + Constants.INT_2;
+ break;
+ case "top":
+ labelNum = labelNum + Constants.INT_4;
+ break;
+ case "bottom":
+ labelNum = labelNum + Constants.INT_8;
+ break;
+ default:
+ break;
+ }
+ }
+ return labelNum;
+ }
+
+ /**
+ * getAlign
+ *
+ * @param align align
+ * @return int
+ */
+ public static int getAlign(String align) {
+ switch (align) {
+ case "bottom":
+ return TextAlignment.BOTTOM;
+ case "center":
+ return TextAlignment.CENTER;
+ case "end":
+ return TextAlignment.END;
+ case "horizontal_center":
+ return TextAlignment.HORIZONTAL_CENTER;
+ case "left":
+ return TextAlignment.LEFT;
+ case "right":
+ return TextAlignment.RIGHT;
+ case "start":
+ return TextAlignment.START;
+ case "top":
+ return TextAlignment.TOP;
+ case "vertical_center":
+ return TextAlignment.VERTICAL_CENTER;
+ default:
+ return TextAlignment.LEFT;
+ }
+ }
+
+ /**
+ * getHorizontalPositioning
+ *
+ * @param horizontalPositioning horizontalPositioning
+ * @return HorizontalPositioning
+ */
+ public static HorizontalPositioning getHorizontalPositioning(String horizontalPositioning) {
+ switch (horizontalPositioning) {
+ case "absolute_from_left":
+ return HorizontalPositioning.ABSOLUTE_FROM_LEFT;
+ case "absolute_from_right":
+ return HorizontalPositioning.ABSOLUTE_FROM_RIGHT;
+ case "absolute_from_center":
+ return HorizontalPositioning.ABSOLUTE_FROM_CENTER;
+ case "relative_to_left":
+ return HorizontalPositioning.RELATIVE_TO_LEFT;
+ case "relative_to_right":
+ return HorizontalPositioning.RELATIVE_TO_RIGHT;
+ case "relative_to_center":
+ return HorizontalPositioning.RELATIVE_TO_CENTER;
+ default:
+ return HorizontalPositioning.ABSOLUTE_FROM_LEFT;
+ }
+ }
+
+ /**
+ * VerticalPositioning
+ *
+ * @param verticalPositioning VerticalPositioning
+ * @return VerticalPositioning
+ */
+ public static VerticalPositioning getVerticalPositioning(String verticalPositioning) {
+ switch (verticalPositioning) {
+ case "absolute_from_top":
+ return VerticalPositioning.ABSOLUTE_FROM_TOP;
+ case "absolute_from_bootom":
+ return VerticalPositioning.ABSOLUTE_FROM_BOTTOM;
+ case "absolute_from_center":
+ return VerticalPositioning.ABSOLUTE_FROM_CENTER;
+ case "relative_to_top":
+ return VerticalPositioning.RELATIVE_TO_TOP;
+ case "relative_to_bootom":
+ return VerticalPositioning.RELATIVE_TO_BOTTOM;
+ case "relative_to_center":
+ return VerticalPositioning.RELATIVE_TO_CENTER;
+ default:
+ return VerticalPositioning.ABSOLUTE_FROM_TOP;
+ }
+ }
+
+ /**
+ * getSizeMode
+ *
+ * @param sizeMode sizeMode
+ * @return SizeMode
+ */
+ public static SizeMode getSizeMode(String sizeMode) {
+ switch (sizeMode) {
+ case "fill":
+ return SizeMode.FILL;
+ case "absolute":
+ return SizeMode.ABSOLUTE;
+ case "relative":
+ return SizeMode.RELATIVE;
+ default:
+ return SizeMode.FILL;
+ }
+ }
+}
diff --git a/ohosplot_core/src/main/java/com/ohosplot/style/FullScreenGraphStyleBean.java b/ohosplot_core/src/main/java/com/ohosplot/style/FullScreenGraphStyleBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..2c9f14b1d3e2c93ea2f141ef56b94c47b4865fac
--- /dev/null
+++ b/ohosplot_core/src/main/java/com/ohosplot/style/FullScreenGraphStyleBean.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.style;
+
+import com.ohosplot.ResourceTable;
+
+import ohos.app.Context;
+import ohos.global.resource.NotExistException;
+import ohos.global.resource.ResourceManager;
+import ohos.global.resource.WrongTypeException;
+
+import java.io.IOException;
+
+/**
+ * FullScreenGraphStyleBean
+ *
+ * @since 2021-07-22
+ */
+public class FullScreenGraphStyleBean extends BaseStyleBean {
+ /**
+ * FullScreenGraphStyleBean
+ *
+ * @param context context
+ */
+ public FullScreenGraphStyleBean(Context context) {
+ super(context);
+
+ ResourceManager resManager = context.getResourceManager();
+ try {
+ getStyleMap().put("graphMarginTop",0);
+ getStyleMap().put("graphMarginBottom",0);
+ getStyleMap().put("graphMarginLeft",0);
+ getStyleMap().put("graphMarginRight",0);
+ getStyleMap().put("graphHeightMode",
+ getSizeMode(resManager.getElement(ResourceTable.String_graphHeightMode).getString()));
+ getStyleMap().put("graphWidthMode",
+ getSizeMode(resManager.getElement(ResourceTable.String_graphWidthMode).getString()));
+ getStyleMap().put("graphHeight",0);
+ getStyleMap().put("graphWidth",0);
+ getStyleMap().put("domainLineThickness",
+ resManager.getElement(ResourceTable.Float_domainLineThickness).getFloat());
+ getStyleMap().put("graphHorizontalPositioning",
+ getHorizontalPositioning(resManager.getElement(
+ ResourceTable.String_graphHorizontalPositioning).getString()));
+ getStyleMap().put("graphVerticalPositioning",
+ getHorizontalPositioning(resManager.getElement(
+ ResourceTable.String_graphVerticalPositioning).getString()));
+ getStyleMap().put("rangeLineThickness",resManager.getElement(
+ ResourceTable.Float_rangeLineThickness).getFloat());
+ getStyleMap().put("graphAnchor",getAnchor(
+ resManager.getElement(ResourceTable.String_graphAnchor).getString()));
+ getStyleMap().put("legendVisible",false);
+ getStyleMap().put("graphHorizontalPosition",0);
+ getStyleMap().put("graphVerticalPosition",0);
+ } catch (IOException | NotExistException | WrongTypeException e) {
+ return;
+ }
+ }
+}
diff --git a/ohosplot_core/src/main/java/com/ohosplot/style/MinimalistDarkStyleBean.java b/ohosplot_core/src/main/java/com/ohosplot/style/MinimalistDarkStyleBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..5517dc709ff9efe8e3a54c0c0d04ac058b9030cc
--- /dev/null
+++ b/ohosplot_core/src/main/java/com/ohosplot/style/MinimalistDarkStyleBean.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.style;
+
+import com.ohosplot.ResourceTable;
+
+import ohos.agp.utils.Color;
+import ohos.app.Context;
+import ohos.global.resource.NotExistException;
+import ohos.global.resource.ResourceManager;
+import ohos.global.resource.WrongTypeException;
+
+import java.io.IOException;
+
+/**
+ * MinimalistDarkStyleBean
+ *
+ * @since 2021-07-22
+ */
+public class MinimalistDarkStyleBean extends MinimalistStyleBean {
+ /**
+ * MinimalistDarkStyleBean
+ *
+ * @param context context
+ */
+ public MinimalistDarkStyleBean(Context context) {
+ super(context);
+ ResourceManager resManager = context.getResourceManager();
+ try {
+ Color apBlack = new Color(resManager.getElement(ResourceTable.Color_ap_black).getColor());
+ Color apTransparent = new Color(resManager.getElement(ResourceTable.Color_ap_transparent).getColor());
+ Color apWhite = new Color(resManager.getElement(ResourceTable.Color_ap_white).getColor());
+
+ getStyleMap().put("backgroundColor",apBlack);
+ getStyleMap().put("gridBackgroundColor",apBlack);
+ getStyleMap().put("borderColor",apTransparent);
+ getStyleMap().put("domainLineColor",apWhite);
+ getStyleMap().put("rangeLineColor",apWhite);
+ } catch (IOException | NotExistException | WrongTypeException e) {
+ return;
+ }
+ }
+}
diff --git a/ohosplot_core/src/main/java/com/ohosplot/style/MinimalistLightStyleBean.java b/ohosplot_core/src/main/java/com/ohosplot/style/MinimalistLightStyleBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..5e2bd3bc6460211e8e702df545555b5411c8f85e
--- /dev/null
+++ b/ohosplot_core/src/main/java/com/ohosplot/style/MinimalistLightStyleBean.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.style;
+
+import com.ohosplot.ResourceTable;
+
+import ohos.agp.utils.Color;
+import ohos.app.Context;
+import ohos.global.resource.NotExistException;
+import ohos.global.resource.ResourceManager;
+import ohos.global.resource.WrongTypeException;
+
+import java.io.IOException;
+
+/**
+ * MinimalistLightStyleBean
+ *
+ * @since 2021-07-22
+ */
+public class MinimalistLightStyleBean extends MinimalistStyleBean {
+ /**
+ * MinimalistLightStyleBean
+ *
+ * @param context context
+ */
+ public MinimalistLightStyleBean(Context context) {
+ super(context);
+ ResourceManager resManager = context.getResourceManager();
+ try {
+ Color apBlack = new Color(resManager.getElement(ResourceTable.Color_ap_black).getColor());
+ Color apTransparent = new Color(resManager.getElement(ResourceTable.Color_ap_transparent).getColor());
+ Color apWhite = new Color(resManager.getElement(ResourceTable.Color_ap_white).getColor());
+ getStyleMap().put("backgroundColor",apWhite);
+ getStyleMap().put("gridBackgroundColor",apWhite);
+ getStyleMap().put("borderColor",apTransparent);
+ getStyleMap().put("domainLineColor",apBlack);
+ getStyleMap().put("rangeLineColor",apBlack);
+ } catch (IOException | NotExistException | WrongTypeException e) {
+ return;
+ }
+ }
+}
diff --git a/ohosplot_core/src/main/java/com/ohosplot/style/MinimalistStyleBean.java b/ohosplot_core/src/main/java/com/ohosplot/style/MinimalistStyleBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..f37c92ddcad23341eaf35087d04ea719228c0ac8
--- /dev/null
+++ b/ohosplot_core/src/main/java/com/ohosplot/style/MinimalistStyleBean.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.style;
+
+import ohos.app.Context;
+
+/**
+ * MinimalistStyleBean
+ *
+ * @since 2021-07-22
+ */
+public class MinimalistStyleBean extends FullScreenGraphStyleBean {
+ /**
+ * MinimalistStyleBean
+ *
+ * @param context context
+ */
+ public MinimalistStyleBean(Context context) {
+ super(context);
+ getStyleMap().put("domainLineExtension",0);
+ getStyleMap().put("rangeLineExtension",0);
+ getStyleMap().put("lineLabels",0);
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/Anchor.java b/ohosplot_core/src/main/java/com/ohosplot/ui/Anchor.java
similarity index 64%
rename from androidplot-core/src/main/java/com/androidplot/ui/Anchor.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/Anchor.java
index e5986556774698fbba4b1fcb099bf242e0e8e0af..243af035d79d7ce2096194c10dc331d68287584d 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/Anchor.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/Anchor.java
@@ -14,20 +14,50 @@
* limitations under the License.
*/
-package com.androidplot.ui;
+package com.ohosplot.ui;
/**
- * Enumeration of possible anchor positions that a {@link com.androidplot.ui.widget.Widget} can use. There are a total
+ * Enumeration of possible anchor positions that a {@link com.ohosplot.ui.widget.Widget} can use.There are a total
* 8 possible anchor positions representing each corner of the Widget and the point exactly between each corner.
+ *
+ * @since 2021-07-22
*/
public enum Anchor {
+ /**
+ * TOP_MIDDLE
+ */
TOP_MIDDLE,
- LEFT_TOP, // default
+ /**
+ * LEFT_TOP
+ * default
+ */
+ LEFT_TOP,
+ /**
+ * LEFT_MIDDLE
+ */
LEFT_MIDDLE,
+ /**
+ * LEFT_BOTTOM
+ */
LEFT_BOTTOM,
+ /**
+ * RIGHT_TOP
+ */
RIGHT_TOP,
+ /**
+ * RIGHT_MIDDLE
+ */
RIGHT_MIDDLE,
+ /**
+ * RIGHT_BOTTOM
+ */
RIGHT_BOTTOM,
+ /**
+ * BOTTOM_MIDDLE
+ */
BOTTOM_MIDDLE,
+ /**
+ * CENTER
+ */
CENTER
}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/BoxModel.java b/ohosplot_core/src/main/java/com/ohosplot/ui/BoxModel.java
similarity index 78%
rename from androidplot-core/src/main/java/com/androidplot/ui/BoxModel.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/BoxModel.java
index 51ab2292cbabd2c91d1e3a93eb77e8049acfae28..5fc6e3db1ca77e73186d5f4eb87a06122d5e7058 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/BoxModel.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/BoxModel.java
@@ -1,162 +1,175 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-import android.graphics.RectF;
-
-/**
- * Convenience implementation of {@link BoxModelable}.
- */
-public class BoxModel implements BoxModelable{
-
- private float marginLeft;
- private float marginTop;
- private float marginRight;
- private float marginBottom;
-
-
- private float paddingLeft;
- private float paddingTop;
- private float paddingRight;
- private float paddingBottom;
-
- /**
- * Default with 0 for all padding / margin values
- */
- public BoxModel() {
- // nothing to do
- }
-
- @SuppressWarnings("SameParameterValue")
- public BoxModel(float marginLeft, float marginTop, float marginRight, float marginBottom,
- float paddingLeft, float paddingTop, float paddingRight, float paddingBottom) {
- this.marginLeft = marginLeft;
- this.marginTop = marginTop;
- this.marginRight = marginRight;
- this.marginBottom = marginBottom;
-
- this.paddingLeft = paddingLeft;
- this.paddingTop = paddingTop;
- this.paddingRight = paddingRight;
- this.paddingBottom = paddingBottom;
- }
-
- /**
- * Returns a RectF instance describing the inner edge of the margin layer.
- * @param boundsRect
- * @return
- */
- public RectF getMarginatedRect(RectF boundsRect) {
- return new RectF( boundsRect.left + getMarginLeft(),
- boundsRect.top + getMarginTop(),
- boundsRect.right - getMarginRight(),
- boundsRect.bottom - getMarginBottom());
- }
-
- /**
- * Returns a RectF instance describing the inner edge of the padding layer.
- * @param marginRect
- * @return
- */
- public RectF getPaddedRect(RectF marginRect) {
- return new RectF(marginRect.left + getPaddingLeft(),
- marginRect.top + getPaddingTop(),
- marginRect.right - getPaddingRight(),
- marginRect.bottom - getPaddingBottom());
- }
-
- @Override
- public void setMargins(float left, float top, float right, float bottom) {
- setMarginLeft(left);
- setMarginTop(top);
- setMarginRight(right);
- setMarginBottom(bottom);
- }
-
- @Override
- public void setPadding(float left, float top, float right, float bottom) {
- setPaddingLeft(left);
- setPaddingTop(top);
- setPaddingRight(right);
- setPaddingBottom(bottom);
- }
-
-
- public float getMarginLeft() {
- return marginLeft;
- }
-
- public void setMarginLeft(float marginLeft) {
- this.marginLeft = marginLeft;
- }
-
- public float getMarginTop() {
- return marginTop;
- }
-
- public void setMarginTop(float marginTop) {
- this.marginTop = marginTop;
- }
-
- public float getMarginRight() {
- return marginRight;
- }
-
- public void setMarginRight(float marginRight) {
- this.marginRight = marginRight;
- }
-
- public float getMarginBottom() {
- return marginBottom;
- }
-
- public void setMarginBottom(float marginBottom) {
- this.marginBottom = marginBottom;
- }
-
- public float getPaddingLeft() {
- return paddingLeft;
- }
-
- public void setPaddingLeft(float paddingLeft) {
- this.paddingLeft = paddingLeft;
- }
-
- public float getPaddingTop() {
- return paddingTop;
- }
-
- public void setPaddingTop(float paddingTop) {
- this.paddingTop = paddingTop;
- }
-
- public float getPaddingRight() {
- return paddingRight;
- }
-
- public void setPaddingRight(float paddingRight) {
- this.paddingRight = paddingRight;
- }
-
- public float getPaddingBottom() {
- return paddingBottom;
- }
-
- public void setPaddingBottom(float paddingBottom) {
- this.paddingBottom = paddingBottom;
- }
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+import ohos.agp.utils.RectFloat;
+
+/**
+ * Convenience implementation of {@link BoxModelable}.
+ *
+ * @since 2021-07-22
+ */
+public class BoxModel implements BoxModelable {
+ private float marginLeft;
+ private float marginTop;
+ private float marginRight;
+ private float marginBottom;
+
+ private float paddingLeft;
+ private float paddingTop;
+ private float paddingRight;
+ private float paddingBottom;
+
+ /**
+ * Default with 0 for all padding / margin values
+ */
+ public BoxModel() {
+ // nothing to do
+ }
+
+ /**
+ * BoxModel
+ *
+ * @param marginLeft marginLeft
+ * @param marginTop marginTop
+ * @param marginRight marginRight
+ * @param marginBottom marginBottom
+ * @param paddingLeft paddingLeft
+ * @param paddingTop paddingTop
+ * @param paddingRight paddingRight
+ * @param paddingBottom paddingBottom
+ */
+ @SuppressWarnings("SameParameterValue")
+ public BoxModel(float marginLeft, float marginTop, float marginRight, float marginBottom,
+ float paddingLeft, float paddingTop, float paddingRight, float paddingBottom) {
+ this.marginLeft = marginLeft;
+ this.marginTop = marginTop;
+ this.marginRight = marginRight;
+ this.marginBottom = marginBottom;
+
+ this.paddingLeft = paddingLeft;
+ this.paddingTop = paddingTop;
+ this.paddingRight = paddingRight;
+ this.paddingBottom = paddingBottom;
+ }
+
+ /**
+ * Returns a RectFloat instance describing the inner edge of the margin layer.
+ *
+ * @param boundsRect boundsRect
+ * @return getMarginatedRect
+ */
+ public RectFloat getMarginatedRect(RectFloat boundsRect) {
+ return new RectFloat(boundsRect.left + getMarginLeft(),
+ boundsRect.top + getMarginTop(),
+ boundsRect.right - getMarginRight(),
+ boundsRect.bottom - getMarginBottom());
+ }
+
+ /**
+ * Returns a RectFloat instance describing the inner edge of the padding layer.
+ *
+ * @param marginRect marginRect
+ * @return RectFloat
+ */
+ public RectFloat getPaddedRect(RectFloat marginRect) {
+ return new RectFloat(marginRect.left + getPaddingLeft(),
+ marginRect.top + getPaddingTop(),
+ marginRect.right - getPaddingRight(),
+ marginRect.bottom - getPaddingBottom());
+ }
+
+ @Override
+ public void setMargins(float left, float top, float right, float bottom) {
+ setMarginLeft(left);
+ setMarginTop(top);
+ setMarginRight(right);
+ setMarginBottom(bottom);
+ }
+
+ @Override
+ public void setPadding(float left, float top, float right, float bottom) {
+ setPaddingLeft(left);
+ setPaddingTop(top);
+ setPaddingRight(right);
+ setPaddingBottom(bottom);
+ }
+
+ public float getMarginLeft() {
+ return marginLeft;
+ }
+
+ public void setMarginLeft(float marginLeft) {
+ this.marginLeft = marginLeft;
+ }
+
+ public float getMarginTop() {
+ return marginTop;
+ }
+
+ public void setMarginTop(float marginTop) {
+ this.marginTop = marginTop;
+ }
+
+ public float getMarginRight() {
+ return marginRight;
+ }
+
+ public void setMarginRight(float marginRight) {
+ this.marginRight = marginRight;
+ }
+
+ public float getMarginBottom() {
+ return marginBottom;
+ }
+
+ public void setMarginBottom(float marginBottom) {
+ this.marginBottom = marginBottom;
+ }
+
+ public float getPaddingLeft() {
+ return paddingLeft;
+ }
+
+ public void setPaddingLeft(float paddingLeft) {
+ this.paddingLeft = paddingLeft;
+ }
+
+ public float getPaddingTop() {
+ return paddingTop;
+ }
+
+ public void setPaddingTop(float paddingTop) {
+ this.paddingTop = paddingTop;
+ }
+
+ public float getPaddingRight() {
+ return paddingRight;
+ }
+
+ public void setPaddingRight(float paddingRight) {
+ this.paddingRight = paddingRight;
+ }
+
+ public float getPaddingBottom() {
+ return paddingBottom;
+ }
+
+ public void setPaddingBottom(float paddingBottom) {
+ this.paddingBottom = paddingBottom;
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/BoxModelable.java b/ohosplot_core/src/main/java/com/ohosplot/ui/BoxModelable.java
similarity index 49%
rename from androidplot-core/src/main/java/com/androidplot/ui/BoxModelable.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/BoxModelable.java
index 9c953b4516ba44ce77e1627ba25f44c44ad34b2d..d75c79da44005f374ce696d856822cb24dffbf3a 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/BoxModelable.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/BoxModelable.java
@@ -1,79 +1,178 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-import android.graphics.RectF;
-
-/**
- * Defines the properties of a BoxModel as used
- * by Androidplot. Essentially, the BoxModel composes three nested (but not necessarily concentric) rectangles:
- * * The bounding box, which is the outer-most box.
- * * The marginated box, which is calculated by applying the margin insets to the bounding box.
- * * The padded box, which is calculated by applying the padding insets to the marginated box.
- */
-public interface BoxModelable {
- /**
- * Returns a RectF instance describing the inner edge of the margin layer.
- * @param boundsRect
- * @return
- */
- RectF getMarginatedRect(RectF boundsRect);
-
- /**
- * Returns a RectF instance describing the inner edge of the padding layer.
- * @param marginRect
- * @return
- */
- RectF getPaddedRect(RectF marginRect);
-
-
- void setMargins(float left, float top, float right, float bottom);
-
- void setPadding(float left, float top, float right, float bottom);
-
- float getMarginLeft();
-
- void setMarginLeft(float marginLeft);
-
- float getMarginTop();
-
- void setMarginTop(float marginTop);
-
- float getMarginRight();
-
- void setMarginRight(float marginRight);
-
- float getMarginBottom();
-
- void setMarginBottom(float marginBottm);
-
- float getPaddingLeft();
-
- void setPaddingLeft(float paddingLeft);
-
- float getPaddingTop();
-
- void setPaddingTop(float paddingTop);
-
- float getPaddingRight();
-
- void setPaddingRight(float paddingRight);
-
- float getPaddingBottom();
-
- void setPaddingBottom(float paddingBottom);
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+import ohos.agp.utils.RectFloat;
+
+/**
+ * Defines the properties of a BoxModel as used
+ * by Androidplot. Essentially, the BoxModel composes three nested (but not necessarily concentric) rectangles:
+ * * The bounding box, which is the outer-most box.
+ * * The marginated box, which is calculated by applying the margin insets to the bounding box.
+ * * The padded box, which is calculated by applying the padding insets to the marginated box.
+ *
+ * @since 2021-07-22
+ */
+public interface BoxModelable {
+ /**
+ * Returns a RectFloat instance describing the inner edge of the margin layer.
+ *
+ * @param boundsRect boundsRect
+ * @return getMarginatedRect
+ */
+ RectFloat getMarginatedRect(RectFloat boundsRect);
+
+ /**
+ * Returns a RectFloat instance describing the inner edge of the padding layer.
+ *
+ * @param marginRect marginRect
+ * @return RectFloat
+ */
+ RectFloat getPaddedRect(RectFloat marginRect);
+
+ /**
+ * setMargins
+ *
+ * @param left left
+ * @param top top
+ * @param right right
+ * @param bottom right
+ */
+ void setMargins(float left, float top, float right, float bottom);
+
+ /**
+ * setPadding
+ *
+ * @param left left
+ * @param top top
+ * @param right right
+ * @param bottom bottom
+ */
+ void setPadding(float left, float top, float right, float bottom);
+
+ /**
+ * getMarginLeft
+ *
+ * @return float
+ */
+ float getMarginLeft();
+
+ /**
+ * setMarginLeft
+ *
+ * @param marginLeft marginLeft
+ */
+ void setMarginLeft(float marginLeft);
+
+ /**
+ * getMarginTop
+ *
+ * @return float
+ */
+ float getMarginTop();
+
+ /**
+ * setMarginTop
+ *
+ * @param marginTop marginTop
+ */
+ void setMarginTop(float marginTop);
+
+ /**
+ * getMarginRight
+ *
+ * @return float
+ */
+ float getMarginRight();
+
+ /**
+ * marginRight
+ *
+ * @param marginRight marginRight
+ */
+ void setMarginRight(float marginRight);
+
+ /**
+ * getMarginBottom
+ *
+ * @return float
+ */
+ float getMarginBottom();
+
+ /**
+ * setMarginBottom
+ *
+ * @param marginBottm marginBottm
+ */
+ void setMarginBottom(float marginBottm);
+
+ /**
+ * getPaddingLeft
+ *
+ * @return float
+ */
+ float getPaddingLeft();
+
+ /**
+ * setPaddingLeft
+ *
+ * @param paddingLeft paddingLeft
+ */
+ void setPaddingLeft(float paddingLeft);
+
+ /**
+ * getPaddingTop
+ *
+ * @return float
+ */
+ float getPaddingTop();
+
+ /**
+ * setPaddingTop
+ *
+ * @param paddingTop paddingTop
+ */
+ void setPaddingTop(float paddingTop);
+
+ /**
+ * getPaddingRight
+ *
+ * @return float
+ */
+ float getPaddingRight();
+
+ /**
+ * setPaddingRight
+ *
+ * @param paddingRight paddingRight
+ */
+ void setPaddingRight(float paddingRight);
+
+ /**
+ * getPaddingBottom
+ *
+ * @return float
+ */
+ float getPaddingBottom();
+
+ /**
+ * setPaddingBottom
+ *
+ * @param paddingBottom paddingBottom
+ */
+ void setPaddingBottom(float paddingBottom);
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/DynamicTableModel.java b/ohosplot_core/src/main/java/com/ohosplot/ui/DynamicTableModel.java
similarity index 64%
rename from androidplot-core/src/main/java/com/androidplot/ui/DynamicTableModel.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/DynamicTableModel.java
index ff973b9d47fc3cea7a9c288b91f259d0dd95d904..3a7e89f421825a01fe4cc2d62568a5de5f8a7d71 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/DynamicTableModel.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/DynamicTableModel.java
@@ -1,228 +1,259 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-import android.graphics.RectF;
-
-import java.util.Iterator;
-
-/**
- * Encapsulates the visual aspects of a table; number of rows and columns
- * and the height and width in pixels of each element within the table.
- * There is no support (yet) for variable size cells within a table; all
- * cells within a table share the same dimensions.
- *
- * The DynamicTableModel provides an Iterator implementation which returns a RectF
- * of each subsequent cell, based on the order of the plot. Tables with
- * an order of COLUMN_MAJOR are traversed left to right column by column until
- * the end of the row is reached, then proceeding to the next row.
- * Tables with an order of ROW_MAJOR are traversed top to bottom row by row
- * until the end of the row is reached, then proceeding to the next column.
- */
-public class DynamicTableModel extends TableModel {
-
- private int numRows;
- private int numColumns;
-
- /**
- * Convenience method. Sets order to ROW_MAJOR.
- * @param numColumns
- * @param numRows
- */
- public DynamicTableModel(int numColumns, int numRows) {
- this(numColumns, numRows, TableOrder.ROW_MAJOR);
-
- }
-
- public DynamicTableModel(int numColumns, int numRows, TableOrder order) {
- super(order);
- this.numColumns = numColumns;
- this.numRows = numRows;
- }
-
- @Override
- public TableModelIterator getIterator(RectF tableRect, int totalElements) {
- return new TableModelIterator(this, tableRect, totalElements);
- }
-
- /**
- * Calculates the dimensions of a single element of this table with
- * tableRect representing the overall dimensions of the table.
- * @param tableRect Dimensions/position of the table
- * @return a RectF representing the first (top-left) element in
- * the tableRect passed in.
- */
- public RectF getCellRect(RectF tableRect, int numElements) {
- RectF cellRect = new RectF();
- cellRect.left = tableRect.left;
- cellRect.top = tableRect.top;
- cellRect.bottom = tableRect.top + calculateCellSize(tableRect, TableModel.Axis.ROW, numElements);
- cellRect.right = tableRect.left + calculateCellSize(tableRect, TableModel.Axis.COLUMN, numElements);
- return cellRect;
- }
-
- /**
- * Figure out the size of a single cell across the specified axis.
- * @param tableRect
- * @param axis
- * @param numElementsInTable
- * @return
- */
- private float calculateCellSize(RectF tableRect,
- Axis axis,
- int numElementsInTable) {
- int axisElements = 0;
-
- float axisSizePix = 0;
- switch (axis) {
- case ROW:
- axisElements = numRows;
- axisSizePix = tableRect.height();
- break;
- case COLUMN:
- axisElements = numColumns;
- axisSizePix = tableRect.width();
- break;
- }
- if(axisElements != 0) {
- return axisSizePix / axisElements;
- } else {
- return axisSizePix / numElementsInTable;
- }
- }
-
-
-
- public int getNumRows() {
- return numRows;
- }
-
- public void setNumRows(int numRows) {
- this.numRows = numRows;
- }
-
- public int getNumColumns() {
- return numColumns;
- }
-
- public void setNumColumns(int numColumns) {
- this.numColumns = numColumns;
- }
-
- private class TableModelIterator implements Iterator {
- private boolean isOk = true;
- int lastColumn = 0; // most recent column iterated
- int lastRow = 0; // most recent row iterated
- int lastElement = 0; // last element index iterated
- private DynamicTableModel dynamicTableModel;
- private RectF tableRect;
- private RectF lastElementRect;
- private int totalElements;
- private TableOrder order;
-
- private int calculatedNumElements;
- private int calculatedRows; // number of rows to be iterated
- private int calculatedColumns; // number of columns to be iterated
-
- public TableModelIterator(DynamicTableModel dynamicTableModel, RectF tableRect, int totalElements) {
- this.dynamicTableModel = dynamicTableModel;
- this.tableRect = tableRect;
- this.totalElements = totalElements;
- order = dynamicTableModel.getOrder();
-
- // unlimited columns:
- if(dynamicTableModel.getNumColumns() == 0 && dynamicTableModel.getNumRows() >= 1) {
- calculatedRows = dynamicTableModel.getNumRows();
-
- // round up:
- calculatedColumns = Float.valueOf((totalElements / (float) calculatedRows) + 0.5f).intValue();
- } else if(dynamicTableModel.getNumRows() == 0 && dynamicTableModel.getNumColumns() >= 1) {
- calculatedColumns = dynamicTableModel.getNumColumns();
- calculatedRows = Float.valueOf((totalElements / (float) calculatedColumns) + 0.5f).intValue();
- // unlimited rows and columns (impossible) so default a single row with n columns:
- }else if(dynamicTableModel.getNumColumns() == 0 && dynamicTableModel.getNumRows() == 0) {
- calculatedRows = 1;
- calculatedColumns = totalElements;
- } else {
- calculatedRows = dynamicTableModel.getNumRows();
- calculatedColumns = dynamicTableModel.getNumColumns();
- }
- calculatedNumElements = calculatedRows * calculatedColumns;
- lastElementRect = dynamicTableModel.getCellRect(tableRect, totalElements);
- }
-
- @Override
- public boolean hasNext() {
- return isOk && lastElement < calculatedNumElements;
- }
-
- @Override
- public RectF next() {
- if(!hasNext()) {
- isOk = false;
- throw new IndexOutOfBoundsException();
- }
-
- if (lastElement == 0) {
- lastElement++;
- return lastElementRect;
- }
-
- RectF nextElementRect = new RectF(lastElementRect);
-
- switch (order) {
- case ROW_MAJOR:
- if (dynamicTableModel.getNumColumns() > 0 && lastColumn >= (dynamicTableModel.getNumColumns() - 1)) {
- // move to the begining of the next row down:// move to the begining of the next row down:
- nextElementRect.offsetTo(tableRect.left, lastElementRect.bottom);
- lastColumn = 0;
- lastRow++;
- } else {
- // move to the next column over:
- nextElementRect.offsetTo(lastElementRect.right, lastElementRect.top);
- lastColumn++;
- }
- break;
- case COLUMN_MAJOR:
- if (dynamicTableModel.getNumRows() > 0 && lastRow >= (dynamicTableModel.getNumRows() - 1)) {
- // move to the top of the next column over:
- nextElementRect.offsetTo(lastElementRect.right, tableRect.top);
- lastRow = 0;
- lastColumn++;
- } else {
- // move to the next row down:
- nextElementRect.offsetTo(lastElementRect.left, lastElementRect.bottom);
- lastRow++;
- }
- break;
- // unknown/unsupported enum val:
- default:
- isOk = false;
- throw new IllegalArgumentException();
- }
- lastElement++;
- lastElementRect = nextElementRect;
- return nextElementRect;
-
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+import com.ohosplot.util.Constants;
+
+import ohos.agp.utils.RectFloat;
+
+import java.util.Iterator;
+
+/**
+ * Encapsulates the visual aspects of a table; number of rows and columns
+ * and the height and width in pixels of each element within the table.
+ * There is no support (yet) for variable size cells within a table; all
+ * cells within a table share the same dimensions.
+ *
+ * The DynamicTableModel provides an Iterator implementation which returns a RectFloat
+ * of each subsequent cell, based on the order of the plot. Tables with
+ * an order of COLUMN_MAJOR are traversed left to right column by column until
+ * the end of the row is reached, then proceeding to the next row.
+ * Tables with an order of ROW_MAJOR are traversed top to bottom row by row
+ * until the end of the row is reached, then proceeding to the next column.
+ *
+ * @since 2021-07-22
+ */
+public class DynamicTableModel extends TableModel {
+ private int numRows;
+ private int numColumns;
+
+ /**
+ * Convenience method.Sets order to ROW_MAJOR.
+ *
+ * @param numColumns numColumns
+ * @param numRows numRows
+ */
+ public DynamicTableModel(int numColumns, int numRows) {
+ this(numColumns, numRows, TableOrder.ROW_MAJOR);
+ }
+
+ /**
+ * DynamicTableModel
+ *
+ * @param numColumns numColumns
+ * @param numRows numRows
+ * @param order order
+ */
+ public DynamicTableModel(int numColumns, int numRows, TableOrder order) {
+ super(order);
+ this.numColumns = numColumns;
+ this.numRows = numRows;
+ }
+
+ @Override
+ public TableModelIterator getIterator(RectFloat tableRect, int totalElements) {
+ return new TableModelIterator(this, tableRect, totalElements);
+ }
+
+ /**
+ * Calculates the dimensions of a single element of this table with
+ * tableRect representing the overall dimensions of the table.
+ *
+ * @param tableRect Dimensions/position of the table
+ * @param numElements numElements
+ * @return a RectFloat representing the first (top-left) element in
+ * the tableRect passed in.
+ */
+ public RectFloat getCellRect(RectFloat tableRect, int numElements) {
+ RectFloat cellRect = new RectFloat();
+ cellRect.left = tableRect.left;
+ cellRect.top = tableRect.top;
+ cellRect.bottom = tableRect.top + calculateCellSize(tableRect, Axis.ROW, numElements);
+ cellRect.right = tableRect.left + calculateCellSize(tableRect, Axis.COLUMN, numElements);
+ return cellRect;
+ }
+
+ /**
+ * Figure out the size of a single cell across the specified axis.
+ *
+ * @param tableRect tableRect
+ * @param axis axis
+ * @param numElementsInTable numElementsInTable
+ * @return float
+ */
+ private float calculateCellSize(RectFloat tableRect,
+ Axis axis,
+ int numElementsInTable) {
+ int axisElements = 0;
+ float axisSizePix = 0;
+ switch (axis) {
+ case ROW:
+ axisElements = numRows;
+ axisSizePix = tableRect.getHeight();
+ break;
+ case COLUMN:
+ axisElements = numColumns;
+ axisSizePix = tableRect.getWidth();
+ break;
+ default:
+ break;
+ }
+ if (axisElements != 0) {
+ return axisSizePix / axisElements;
+ } else {
+ return axisSizePix / numElementsInTable;
+ }
+ }
+
+ public int getNumRows() {
+ return numRows;
+ }
+
+ public void setNumRows(int numRows) {
+ this.numRows = numRows;
+ }
+
+ public int getNumColumns() {
+ return numColumns;
+ }
+
+ public void setNumColumns(int numColumns) {
+ this.numColumns = numColumns;
+ }
+
+ /**
+ * TableModelIterator
+ *
+ * @since 2021-07-22
+ */
+ private static class TableModelIterator implements Iterator {
+ // most recent column iterated
+ int lastColumn = 0;
+
+ // most recent row iterated
+ int lastRow = 0;
+
+ // last element index iterated
+ int lastElement = 0;
+ private DynamicTableModel dynamicTableModel;
+ private RectFloat tableRect;
+ private RectFloat lastElementRect;
+ private TableOrder order;
+
+ private int calculatedNumElements;
+
+ // number of rows to be iterated
+ private int calculatedRows;
+
+ // number of columns to be iterated
+ private int calculatedColumns;
+ private boolean isOk = true;
+
+ /**
+ * TableModelIterator
+ *
+ * @param dynamicTableModel dynamicTableModel
+ * @param tableRect tableRect
+ * @param totalElements totalElements
+ */
+ public TableModelIterator(DynamicTableModel dynamicTableModel, RectFloat tableRect, int totalElements) {
+ this.dynamicTableModel = dynamicTableModel;
+ this.tableRect = tableRect;
+ order = dynamicTableModel.getOrder();
+
+ // unlimited columns:
+ if (dynamicTableModel.getNumColumns() == 0 && dynamicTableModel.getNumRows() >= 1) {
+ calculatedRows = dynamicTableModel.getNumRows();
+
+ // round up:
+ calculatedColumns = Float.valueOf(totalElements
+ / (float) calculatedRows + Constants.FLOAT_05).intValue();
+ } else if (dynamicTableModel.getNumRows() == 0 && dynamicTableModel.getNumColumns() >= 1) {
+ calculatedColumns = dynamicTableModel.getNumColumns();
+ calculatedRows = Float.valueOf(totalElements
+ / (float) calculatedColumns + Constants.FLOAT_05).intValue();
+ } else if (dynamicTableModel.getNumColumns() == 0 && dynamicTableModel.getNumRows() == 0) {
+ calculatedRows = 1;
+ calculatedColumns = totalElements;
+ } else {
+ calculatedRows = dynamicTableModel.getNumRows();
+ calculatedColumns = dynamicTableModel.getNumColumns();
+ }
+ calculatedNumElements = calculatedRows * calculatedColumns;
+ lastElementRect = dynamicTableModel.getCellRect(tableRect, totalElements);
+ }
+
+ @Override
+ public boolean hasNext() {
+ return isOk && lastElement < calculatedNumElements;
+ }
+
+ @Override
+ public RectFloat next() {
+ if (!hasNext()) {
+ isOk = false;
+ throw new IndexOutOfBoundsException();
+ }
+
+ if (lastElement == 0) {
+ lastElement++;
+ return lastElementRect;
+ }
+
+ RectFloat nextElementRect = new RectFloat(lastElementRect);
+
+ switch (order) {
+ case ROW_MAJOR:
+ if (dynamicTableModel.getNumColumns() > 0
+ && lastColumn >= (dynamicTableModel.getNumColumns() - 1)) {
+ // move to the begining of the next row down:// move to the begining of the next row down:
+ nextElementRect.translateTo(tableRect.left, lastElementRect.bottom);
+ lastColumn = 0;
+ lastRow++;
+ } else {
+ // move to the next column over:
+ nextElementRect.translateTo(lastElementRect.right, lastElementRect.top);
+ lastColumn++;
+ }
+ break;
+ case COLUMN_MAJOR:
+ if (dynamicTableModel.getNumRows() > 0 && lastRow >= (dynamicTableModel.getNumRows() - 1)) {
+ // move to the top of the next column over:
+ nextElementRect.translateTo(lastElementRect.right, tableRect.top);
+ lastRow = 0;
+ lastColumn++;
+ } else {
+ // move to the next row down:
+ nextElementRect.translateTo(lastElementRect.left, lastElementRect.bottom);
+ lastRow++;
+ }
+ break;
+ default:
+ isOk = false;
+ throw new IllegalArgumentException();
+ }
+ lastElement++;
+ lastElementRect = nextElementRect;
+ return nextElementRect;
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/FixedTableModel.java b/ohosplot_core/src/main/java/com/ohosplot/ui/FixedTableModel.java
similarity index 75%
rename from androidplot-core/src/main/java/com/androidplot/ui/FixedTableModel.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/FixedTableModel.java
index 5bce9e0ba3e89df345c8db85e77765d1e69f87fe..3c0aa7c23e4015fae55216c752615a5e5e28de81 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/FixedTableModel.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/FixedTableModel.java
@@ -1,149 +1,165 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-import android.graphics.RectF;
-
-import java.util.Iterator;
-
-public class FixedTableModel extends TableModel {
- private float cellWidth;
- private float cellHeight;
-
- public FixedTableModel(float cellWidth, float cellHeight, TableOrder order) {
- super(order);
- setCellWidth(cellWidth);
- setCellHeight(cellHeight);
- }
-
- @Override
- public Iterator getIterator(RectF tableRect, int totalElements) {
- return new FixedTableModelIterator(this, tableRect, totalElements);
- }
-
- public float getCellWidth() {
- return cellWidth;
- }
-
- public void setCellWidth(float cellWidth) {
- this.cellWidth = cellWidth;
- }
-
- public float getCellHeight() {
- return cellHeight;
- }
-
- public void setCellHeight(float cellHeight) {
- this.cellHeight = cellHeight;
- }
-
- private class FixedTableModelIterator implements Iterator {
-
- private FixedTableModel model;
- private RectF tableRect;
- private RectF lastRect;
- private int numElements;
- private int lastElement;
- protected FixedTableModelIterator(FixedTableModel model, RectF tableRect, int numElements) {
- this.model = model;
- this.tableRect = tableRect;
- this.numElements = numElements;
- lastRect = new RectF(
- tableRect.left,
- tableRect.top,
- tableRect.left + model.getCellWidth(),
- tableRect.top + model.getCellHeight());
- }
-
- @Override
- public boolean hasNext() {
- // was this the last element or is there no room in either axis for another cell?
- return !(lastElement >= numElements || (isColumnFinished() && isRowFinished()));
- }
-
- private boolean isColumnFinished() {
- return lastRect.bottom + model.getCellHeight() > tableRect.height();
- }
-
- private boolean isRowFinished() {
- return lastRect.right + model.getCellWidth() > tableRect.width();
- }
-
- @Override
- public RectF next() {
- try {
- if (lastElement == 0) {
- return lastRect;
- }
-
- if (lastElement >= numElements) {
- throw new IndexOutOfBoundsException();
- }
- switch (model.getOrder()) {
- case ROW_MAJOR:
- if (isColumnFinished()) {
- moveOverAndUp();
- } else {
- moveDown();
- }
- break;
- case COLUMN_MAJOR:
- if (isRowFinished()) {
- moveDownAndBack();
- } else {
- moveOver();
- }
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return lastRect;
- } finally {
- lastElement++;
- }
- }
-
- private void moveDownAndBack() {
- //RectF rect = new RectF(lastRect);
- lastRect.offsetTo(tableRect.left, lastRect.bottom);
- //return rect;
- }
-
- private void moveOverAndUp() {
- //RectF rect = new RectF(lastRect);
- lastRect.offsetTo(lastRect.right, tableRect.top);
- //return rect;
- }
-
- private void moveOver() {
- //RectF rect = new RectF(lastRect);
- lastRect.offsetTo(lastRect.right, lastRect.top);
- //return rect;
- }
-
- private void moveDown() {
- //RectF rect = new RectF(lastRect);
- lastRect.offsetTo(lastRect.left, lastRect.bottom);
- //return rect;
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+import ohos.agp.utils.RectFloat;
+
+import java.util.Iterator;
+
+/**
+ * FixedTableModel
+ *
+ * @since 2021-07-22
+ */
+public class FixedTableModel extends TableModel {
+ private float cellWidth;
+ private float cellHeight;
+
+ /**
+ * FixedTableModel
+ *
+ * @param cellWidth cellWidth
+ * @param cellHeight cellHeight
+ * @param order order
+ */
+ public FixedTableModel(float cellWidth, float cellHeight, TableOrder order) {
+ super(order);
+ setCellWidth(cellWidth);
+ setCellHeight(cellHeight);
+ }
+
+ @Override
+ public Iterator getIterator(RectFloat tableRect, int totalElements) {
+ return new FixedTableModelIterator(this, tableRect, totalElements);
+ }
+
+ public float getCellWidth() {
+ return cellWidth;
+ }
+
+ public void setCellWidth(float cellWidth) {
+ this.cellWidth = cellWidth;
+ }
+
+ public float getCellHeight() {
+ return cellHeight;
+ }
+
+ public void setCellHeight(float cellHeight) {
+ this.cellHeight = cellHeight;
+ }
+
+ /**
+ * FixedTableModelIterator
+ *
+ * @since 2021-07-22
+ */
+ private static class FixedTableModelIterator implements Iterator {
+ private FixedTableModel model;
+ private RectFloat tableRect;
+ private RectFloat lastRect;
+ private int numElements;
+ private int lastElement;
+
+ /**
+ * FixedTableModelIterator
+ *
+ * @param model model
+ * @param tableRect tableRect
+ * @param numElements numElements
+ */
+ protected FixedTableModelIterator(FixedTableModel model, RectFloat tableRect, int numElements) {
+ this.model = model;
+ this.tableRect = tableRect;
+ this.numElements = numElements;
+ lastRect = new RectFloat(
+ tableRect.left,
+ tableRect.top,
+ tableRect.left + model.getCellWidth(),
+ tableRect.top + model.getCellHeight());
+ }
+
+ @Override
+ public boolean hasNext() {
+ // was this the last element or is there no room in either axis for another cell?
+ return !(lastElement >= numElements || (isColumnFinished() && isRowFinished()));
+ }
+
+ private boolean isColumnFinished() {
+ return lastRect.bottom + model.getCellHeight() > tableRect.getHeight();
+ }
+
+ private boolean isRowFinished() {
+ return lastRect.right + model.getCellWidth() > tableRect.getWidth();
+ }
+
+ @Override
+ public RectFloat next() {
+ try {
+ if (lastElement == 0) {
+ return lastRect;
+ }
+
+ if (lastElement >= numElements) {
+ throw new IndexOutOfBoundsException();
+ }
+ switch (model.getOrder()) {
+ case ROW_MAJOR:
+ if (isColumnFinished()) {
+ moveOverAndUp();
+ } else {
+ moveDown();
+ }
+ break;
+ case COLUMN_MAJOR:
+ if (isRowFinished()) {
+ moveDownAndBack();
+ } else {
+ moveOver();
+ }
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return lastRect;
+ } finally {
+ lastElement++;
+ }
+ }
+
+ private void moveDownAndBack() {
+ lastRect.translateTo(tableRect.left, lastRect.bottom);
+ }
+
+ private void moveOverAndUp() {
+ lastRect.translateTo(lastRect.right, tableRect.top);
+ }
+
+ private void moveOver() {
+ lastRect.translateTo(lastRect.right, lastRect.top);
+ }
+
+ private void moveDown() {
+ lastRect.translateTo(lastRect.left, lastRect.bottom);
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/Formatter.java b/ohosplot_core/src/main/java/com/ohosplot/ui/Formatter.java
similarity index 78%
rename from androidplot-core/src/main/java/com/androidplot/ui/Formatter.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/Formatter.java
index d920ab365456bbfd1626255b7a698d20996f7a64..ee8ea1b7ee9bf3be1202582e079377cad25c6d07 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/Formatter.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/Formatter.java
@@ -1,92 +1,110 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-import android.content.Context;
-import com.androidplot.Plot;
-import com.halfhp.fig.*;
-
-/**
- * Base class of all Formatters. Encapsulates visual elements of a series; line style, color etc.
- * Implementors of this class should include both a default constructor and a one argument
- * constructor in the following form:
- *
- *
- * {@code
- * // provided as a convenience to users; allows instantiation and
- * // xml configuration in a single line.
- * public MyFormatter(Context ctx, int xmlCfgId) {
- * // prevent configuration of classes derived from this one:
- * if (getClass().equals(MyFormatter.class)) {
- * Configurator.configure(ctx, this, xmlCfgId);
- * }
- * }
- *
- */
-public abstract class Formatter {
-
- private boolean isLegendIconEnabled = true;
-
- public Formatter() {}
-
- public Formatter(Context ctx, int xmlCfgId) {
- configure(ctx, xmlCfgId);
- }
-
- public void configure(Context ctx, int xmlCfgId) {
- try {
- Fig.configure(ctx, this, xmlCfgId);
- } catch (FigException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- *
- * @param plot
- * @param
- * @return @return An instance of SeriesRenderer constructed with the specified plot.
- */
- public T getRendererInstance(PlotType plot) {
- return (T) doGetRendererInstance(plot);
- }
-
- /**
- *
- * @return The Class of SeriesRenderer that should be used when rendering series associated
- * with instances of this formatter.
- */
- public abstract Class extends SeriesRenderer> getRendererClass();
-
- /**
- *
- * @return An instance of SeriesRenderer constructed with the specified plot.
- */
- protected abstract SeriesRenderer doGetRendererInstance(PlotType plot);
-
- public boolean isLegendIconEnabled() {
- return isLegendIconEnabled;
- }
-
- /**
- * Sets whether or not a legend icon should be drawn for the series associated with this formatter.
- * @param legendIconEnabled
- */
- public void setLegendIconEnabled(boolean legendIconEnabled) {
- this.isLegendIconEnabled = legendIconEnabled;
- }
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+import com.ohosplot.Plot;
+
+import ohos.app.Context;
+
+/**
+ * Base class of all Formatters. Encapsulates visual elements of a series; line style, color etc.
+ * Implementors of this class should include both a default constructor and a one argument
+ * constructor in the following form:
+ *
+ *
+ * {@code
+ * // provided as a convenience to users; allows instantiation and
+ * // xml configuration in a single line.
+ * public MyFormatter(Context ctx, int xmlCfgId) {
+ * // prevent configuration of classes derived from this one:
+ * if (getClass().equals(MyFormatter.class)) {
+ * Configurator.configure(ctx, this, xmlCfgId);
+ * }
+ * }
+ *
+ *
+ * @param
+ * @since 2021-07-22
+ */
+public abstract class Formatter {
+ private boolean isLegendIconEnabled = true;
+
+ /**
+ * Formatter
+ */
+ public Formatter() {
+ }
+
+ /**
+ * Formatter
+ *
+ * @param ctx ctx
+ * @param xmlCfgId xmlCfgId
+ */
+ public Formatter(Context ctx, int xmlCfgId) {
+ configure(ctx, xmlCfgId);
+ }
+
+ /**
+ * configure
+ *
+ * @param ctx ctx
+ * @param xmlCfgId xmlCfgId
+ */
+ public void configure(Context ctx, int xmlCfgId) {
+ }
+
+ /**
+ * getRendererInstance
+ *
+ * @param plot plot
+ * @param
+ * @return @return An instance of SeriesRenderer constructed with the specified plot.
+ */
+ public T getRendererInstance(PlotType plot) {
+ return (T) doGetRendererInstance(plot);
+ }
+
+ /**
+ * getRendererClass
+ *
+ * @return The Class of SeriesRenderer that should be used when rendering series associated
+ * with instances of this formatter.
+ */
+ public abstract Class extends SeriesRenderer> getRendererClass();
+
+ /**
+ * doGetRendererInstance
+ *
+ * @param plot plot
+ * @return An instance of SeriesRenderer constructed with the specified plot.
+ */
+ protected abstract SeriesRenderer doGetRendererInstance(PlotType plot);
+
+ public boolean isLegendIconEnabled() {
+ return isLegendIconEnabled;
+ }
+
+ /**
+ * Sets whether or not a legend icon should be drawn for the series associated with this formatter.
+ *
+ * @param isEnabled isEnabled
+ */
+ public void setLegendIconEnabled(boolean isEnabled) {
+ this.isLegendIconEnabled = isEnabled;
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/HorizontalPosition.java b/ohosplot_core/src/main/java/com/ohosplot/ui/HorizontalPosition.java
similarity index 68%
rename from androidplot-core/src/main/java/com/androidplot/ui/HorizontalPosition.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/HorizontalPosition.java
index 5d8b1255bf494c174976120c9ae1598ce4db26c7..677985287eb84afbcbe98a884c3de141dfb44b72 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/HorizontalPosition.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/HorizontalPosition.java
@@ -14,10 +14,20 @@
* limitations under the License.
*/
-package com.androidplot.ui;
+package com.ohosplot.ui;
+/**
+ * HorizontalPosition
+ *
+ * @since 2021-07-22
+ */
public class HorizontalPosition extends PositionMetric {
-
+ /**
+ * HorizontalPosition
+ *
+ * @param value value
+ * @param layoutStyle layoutStyle
+ */
public HorizontalPosition(float value, HorizontalPositioning layoutStyle) {
super(value, layoutStyle);
validatePair(value, layoutStyle);
@@ -25,19 +35,24 @@ public class HorizontalPosition extends PositionMetric {
/**
* Throws IllegalArgumentException if there is a problem.
- * @param value
+ *
+ * @param value value
+ * @param layoutStyle layoutStyle
*/
protected void validatePair(float value, HorizontalPositioning layoutStyle) {
switch(layoutStyle) {
case ABSOLUTE_FROM_LEFT:
case ABSOLUTE_FROM_RIGHT:
case ABSOLUTE_FROM_CENTER:
- validateValue(value, PositionMetric.LayoutMode.ABSOLUTE);
+ validateValue(value, LayoutMode.ABSOLUTE);
break;
case RELATIVE_TO_LEFT:
case RELATIVE_TO_RIGHT:
case RELATIVE_TO_CENTER:
- validateValue(value, PositionMetric.LayoutMode.RELATIVE);
+ validateValue(value, LayoutMode.RELATIVE);
+ break;
+ default:
+ break;
}
}
@@ -45,17 +60,17 @@ public class HorizontalPosition extends PositionMetric {
public float getPixelValue(float size) {
switch(getLayoutType()) {
case ABSOLUTE_FROM_LEFT:
- return this.getAbsolutePosition(size, PositionMetric.Origin.FROM_BEGINING);
+ return this.getAbsolutePosition(size, Origin.FROM_BEGINING);
case ABSOLUTE_FROM_RIGHT:
- return this.getAbsolutePosition(size, PositionMetric.Origin.FROM_END);
+ return this.getAbsolutePosition(size, Origin.FROM_END);
case ABSOLUTE_FROM_CENTER:
- return this.getAbsolutePosition(size, PositionMetric.Origin.FROM_CENTER);
+ return this.getAbsolutePosition(size, Origin.FROM_CENTER);
case RELATIVE_TO_LEFT:
- return this.getRelativePosition(size, PositionMetric.Origin.FROM_BEGINING);
+ return this.getRelativePosition(size, Origin.FROM_BEGINING);
case RELATIVE_TO_RIGHT:
- return this.getRelativePosition(size, PositionMetric.Origin.FROM_END);
+ return this.getRelativePosition(size, Origin.FROM_END);
case RELATIVE_TO_CENTER:
- return this.getRelativePosition(size, PositionMetric.Origin.FROM_CENTER);
+ return this.getRelativePosition(size, Origin.FROM_CENTER);
default:
throw new IllegalArgumentException("Unsupported LayoutType: " + this.getLayoutType());
}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/HorizontalPositioning.java b/ohosplot_core/src/main/java/com/ohosplot/ui/HorizontalPositioning.java
similarity index 70%
rename from androidplot-core/src/main/java/com/androidplot/ui/HorizontalPositioning.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/HorizontalPositioning.java
index b7125ea3965b2656f9fbdbc641ac0b5c9dac18e9..701c5d72fed8318169e63f9432006ca0008bf797 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/HorizontalPositioning.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/HorizontalPositioning.java
@@ -14,14 +14,36 @@
* limitations under the License.
*/
-package com.androidplot.ui;
+package com.ohosplot.ui;
+/**
+ * HorizontalPositioning
+ *
+ * @since 2021-07-22
+ */
public enum HorizontalPositioning {
+ /**
+ * ABSOLUTE_FROM_LEFT
+ */
ABSOLUTE_FROM_LEFT,
+ /**
+ * ABSOLUTE_FROM_RIGHT
+ */
ABSOLUTE_FROM_RIGHT,
+ /**
+ * ABSOLUTE_FROM_CENTER
+ */
ABSOLUTE_FROM_CENTER,
+ /**
+ * RELATIVE_TO_LEFT
+ */
RELATIVE_TO_LEFT,
+ /**
+ * RELATIVE_TO_RIGHT
+ */
RELATIVE_TO_RIGHT,
+ /**
+ * RELATIVE_TO_CENTER
+ */
RELATIVE_TO_CENTER
-
}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/Insets.java b/ohosplot_core/src/main/java/com/ohosplot/ui/Insets.java
similarity index 86%
rename from androidplot-core/src/main/java/com/androidplot/ui/Insets.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/Insets.java
index 85325bfe1d14d04be600fc6726f658b5e20541a7..3baed058ab7d80f780bfe64b2162250d0f6c4678 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/Insets.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/Insets.java
@@ -14,20 +14,33 @@
* limitations under the License.
*/
-package com.androidplot.ui;
+package com.ohosplot.ui;
/**
* A set of insets for a rect space.
+ *
+ * @since 2021-07-22
*/
public class Insets {
-
private float top;
private float bottom;
private float left;
private float right;
- public Insets() {}
+ /**
+ * Insets
+ */
+ public Insets() {
+ }
+ /**
+ * Insets
+ *
+ * @param top top
+ * @param bottom bottom
+ * @param left left
+ * @param right right
+ */
public Insets(float top, float bottom, float left, float right) {
this.top = top;
this.bottom = bottom;
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/LayoutManager.java b/ohosplot_core/src/main/java/com/ohosplot/ui/LayoutManager.java
similarity index 53%
rename from androidplot-core/src/main/java/com/androidplot/ui/LayoutManager.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/LayoutManager.java
index 45f79a434083d0b25d85cd39b40781eebaa91e42..ac1fac72f7da72820801b68b42de9209137bcad7 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/LayoutManager.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/LayoutManager.java
@@ -1,257 +1,292 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.PointF;
-import android.graphics.RectF;
-import android.graphics.Region;
-import android.view.MotionEvent;
-import android.view.View;
-
-import com.androidplot.ui.widget.Widget;
-import com.androidplot.util.DisplayDimensions;
-import com.androidplot.util.LinkedLayerList;
-
-public class LayoutManager extends LinkedLayerList
- implements View.OnTouchListener, Resizable {
- private boolean drawAnchorsEnabled = false;
- private Paint anchorPaint;
- private boolean drawOutlinesEnabled = false;
- private Paint outlinePaint;
- private boolean drawOutlineShadowsEnabled = false;
- private Paint outlineShadowPaint;
- private boolean drawMarginsEnabled = false;
- private Paint marginPaint;
- private boolean drawPaddingEnabled = false;
- private Paint paddingPaint;
- private DisplayDimensions displayDims = new DisplayDimensions();
-
- {
- anchorPaint = new Paint();
- anchorPaint.setStyle(Paint.Style.FILL);
- anchorPaint.setColor(Color.GREEN);
- outlinePaint = new Paint();
- outlinePaint.setColor(Color.GREEN);
- outlinePaint.setStyle(Paint.Style.STROKE);
- outlinePaint.setAntiAlias(true);
- outlinePaint.setStrokeWidth(2);
- marginPaint = new Paint();
- marginPaint.setColor(Color.YELLOW);
- marginPaint.setStyle(Paint.Style.FILL);
- marginPaint.setAlpha(200);
- paddingPaint= new Paint();
- paddingPaint.setColor(Color.BLUE);
- paddingPaint.setStyle(Paint.Style.FILL);
- paddingPaint.setAlpha(200);
- }
-
- /**
- * Invoked immediately following XML configuration.
- */
- public synchronized void onPostInit() {
- for(Widget w : elements()) {
- w.onPostInit();
- }
- }
-
- public LayoutManager() {
- }
-
- public void setMarkupEnabled(boolean enabled) {
- setDrawOutlinesEnabled(enabled);
- setDrawAnchorsEnabled(enabled);
- setDrawMarginsEnabled(enabled);
- setDrawPaddingEnabled(enabled);
- setDrawOutlineShadowsEnabled(enabled);
- }
-
- public void draw(Canvas canvas) {
- if(isDrawMarginsEnabled()) {
- drawSpacing(canvas, displayDims.canvasRect, displayDims.marginatedRect, marginPaint);
- }
- if (isDrawPaddingEnabled()) {
- drawSpacing(canvas, displayDims.marginatedRect, displayDims.paddedRect, paddingPaint);
- }
- for (Widget widget : elements()) {
- try {
- canvas.save();
- PositionMetrics metrics = widget.getPositionMetrics();
- float elementWidth = widget.getWidthPix(displayDims.paddedRect.width());
- float elementHeight = widget.getHeightPix(displayDims.paddedRect.height());
- PointF coords = Widget.calculateCoordinates(elementHeight,
- elementWidth, displayDims.paddedRect, metrics);
-
- DisplayDimensions dims = widget.getWidgetDimensions();
-
- if (drawOutlineShadowsEnabled) {
- canvas.drawRect(dims.canvasRect, outlineShadowPaint);
- }
-
- // not positive why this is, but the rect clipped by clipRect is 1 less than the one drawn by drawRect.
- // so this is necessary to avoid clipping borders. I suspect that its a floating point
- // jitter issue.
- if (widget.isClippingEnabled()) {
- canvas.clipRect(dims.canvasRect, Region.Op.INTERSECT);
- }
- widget.draw(canvas);
-
- if (drawMarginsEnabled) {
- drawSpacing(canvas, dims.canvasRect, dims.marginatedRect, getMarginPaint());
- }
-
- if (drawPaddingEnabled) {
- drawSpacing(canvas, dims.marginatedRect, dims.paddedRect, getPaddingPaint());
- }
-
- if (drawAnchorsEnabled) {
- PointF anchorCoords =
- Widget.getAnchorCoordinates(coords.x, coords.y, elementWidth,
- elementHeight, metrics.getAnchor());
- drawAnchor(canvas, anchorCoords);
- }
-
-
- if (drawOutlinesEnabled) {
- canvas.drawRect(dims.canvasRect, outlinePaint);
- }
- } finally {
- canvas.restore();
- }
- }
- }
-
- private static void drawSpacing(Canvas canvas, RectF outer, RectF inner, Paint paint) {
- try {
- canvas.save();
- canvas.clipRect(inner, Region.Op.DIFFERENCE);
- canvas.drawRect(outer, paint);
- } finally {
- canvas.restore();
- }
- }
-
- protected void drawAnchor(Canvas canvas, PointF coords) {
- float anchorSize = 4;
- canvas.drawRect(coords.x-anchorSize, coords.y-anchorSize, coords.x+anchorSize, coords.y+anchorSize, anchorPaint);
-
- }
-
- public boolean isDrawOutlinesEnabled() {
- return drawOutlinesEnabled;
- }
-
- public void setDrawOutlinesEnabled(boolean drawOutlinesEnabled) {
- this.drawOutlinesEnabled = drawOutlinesEnabled;
- }
-
- public Paint getOutlinePaint() {
- return outlinePaint;
- }
-
- public void setOutlinePaint(Paint outlinePaint) {
- this.outlinePaint = outlinePaint;
- }
-
- public boolean isDrawAnchorsEnabled() {
- return drawAnchorsEnabled;
- }
-
- public void setDrawAnchorsEnabled(boolean drawAnchorsEnabled) {
- this.drawAnchorsEnabled = drawAnchorsEnabled;
- }
-
- public boolean isDrawMarginsEnabled() {
- return drawMarginsEnabled;
- }
-
- public void setDrawMarginsEnabled(boolean drawMarginsEnabled) {
- this.drawMarginsEnabled = drawMarginsEnabled;
- }
-
- public Paint getMarginPaint() {
- return marginPaint;
- }
-
- public void setMarginPaint(Paint marginPaint) {
- this.marginPaint = marginPaint;
- }
-
- public boolean isDrawPaddingEnabled() {
- return drawPaddingEnabled;
- }
-
- public void setDrawPaddingEnabled(boolean drawPaddingEnabled) {
- this.drawPaddingEnabled = drawPaddingEnabled;
- }
-
- public Paint getPaddingPaint() {
- return paddingPaint;
- }
-
- public void setPaddingPaint(Paint paddingPaint) {
- this.paddingPaint = paddingPaint;
- }
-
- public boolean isDrawOutlineShadowsEnabled() {
- return drawOutlineShadowsEnabled;
- }
-
- public void setDrawOutlineShadowsEnabled(boolean drawOutlineShadowsEnabled) {
- this.drawOutlineShadowsEnabled = drawOutlineShadowsEnabled;
- if(drawOutlineShadowsEnabled && outlineShadowPaint == null) {
- // use a default shadow effect in the case where none has been set:
- outlineShadowPaint = new Paint();
- outlineShadowPaint.setColor(Color.DKGRAY);
- outlineShadowPaint.setStyle(Paint.Style.FILL);
- outlineShadowPaint.setShadowLayer(3, 5, 5, Color.BLACK);
- }
- }
-
- public Paint getOutlineShadowPaint() {
- return outlineShadowPaint;
- }
-
- public void setOutlineShadowPaint(Paint outlineShadowPaint) {
- this.outlineShadowPaint = outlineShadowPaint;
- }
-
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- return false;
- }
-
- /**
- * Recalculates layouts for all widgets using last set
- * DisplayDimensions. Care should be excersized when choosing when
- * to call this method as it is a relatively slow operation.
- */
- public void refreshLayout() {
- for (Widget widget : elements()) {
- widget.layout(displayDims);
- }
- }
-
- @Override
- public void layout(final DisplayDimensions dims) {
- this.displayDims = dims;
-
- refreshLayout();
- }
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+import com.ohosplot.ui.widget.Widget;
+import com.ohosplot.util.Constants;
+import com.ohosplot.util.DisplayDimensions;
+import com.ohosplot.util.LinkedLayerList;
+
+import ohos.agp.components.Component;
+import ohos.agp.render.BlurDrawLooper;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.MaskFilter;
+import ohos.agp.render.Paint;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.Point;
+import ohos.agp.utils.RectFloat;
+import ohos.multimodalinput.event.TouchEvent;
+
+/**
+ * LayoutManager
+ *
+ * @since 2021-07-22
+ */
+public class LayoutManager extends LinkedLayerList
+ implements Component.TouchEventListener, Resizable {
+ private boolean isDrawAnchorsEnabled = false;
+ private Paint anchorPaint;
+ private boolean isDrawOutlinesEnabled = false;
+ private Paint outlinePaint;
+ private boolean isDrawOutlineShadowsEnabled = false;
+ private Paint outlineShadowPaint;
+ private boolean isDrawMarginsEnabled = false;
+ private Paint marginPaint;
+ private boolean isDrawPaddingEnabled = false;
+ private Paint paddingPaint;
+ private DisplayDimensions displayDims = new DisplayDimensions();
+
+ {
+ anchorPaint = new Paint();
+ anchorPaint.setStyle(Paint.Style.FILL_STYLE);
+ anchorPaint.setColor(Color.GREEN);
+ outlinePaint = new Paint();
+ outlinePaint.setColor(Color.GREEN);
+ outlinePaint.setStyle(Paint.Style.STROKE_STYLE);
+ outlinePaint.setAntiAlias(true);
+ outlinePaint.setStrokeWidth(Constants.INT_2);
+ marginPaint = new Paint();
+ marginPaint.setColor(Color.YELLOW);
+ marginPaint.setStyle(Paint.Style.FILL_STYLE);
+ marginPaint.setAlpha(Constants.FLOAT_078);
+ paddingPaint = new Paint();
+ paddingPaint.setColor(Color.BLUE);
+ paddingPaint.setStyle(Paint.Style.FILL_STYLE);
+ paddingPaint.setAlpha(Constants.FLOAT_078);
+ }
+
+ /**
+ * LayoutManager
+ */
+ public LayoutManager() {
+ }
+
+ /**
+ * Invoked immediately following XML configuration.
+ */
+ public synchronized void onPostInit() {
+ for (Widget widget : elements()) {
+ widget.onPostInit();
+ }
+ }
+
+ /**
+ * setMarkupEnabled
+ *
+ * @param isEnabled isEnabled
+ */
+ public void setMarkupEnabled(boolean isEnabled) {
+ setDrawOutlinesEnabled(isEnabled);
+ setDrawAnchorsEnabled(isEnabled);
+ setDrawMarginsEnabled(isEnabled);
+ setDrawPaddingEnabled(isEnabled);
+ setDrawOutlineShadowsEnabled(isEnabled);
+ }
+
+ /**
+ * draw
+ *
+ * @param canvas canvas
+ */
+ public void draw(Canvas canvas) {
+ if (isDrawMarginsEnabled()) {
+ drawSpacing(canvas, displayDims.canvasRect, displayDims.marginatedRect, marginPaint);
+ }
+ if (isDrawPaddingEnabled()) {
+ drawSpacing(canvas, displayDims.marginatedRect, displayDims.paddedRect, paddingPaint);
+ }
+ for (Widget widget : elements()) {
+ try {
+ canvas.save();
+ PositionMetrics metrics = widget.getPositionMetrics();
+ float elementWidth = widget.getWidthPix(displayDims.paddedRect.getWidth());
+ float elementHeight = widget.getHeightPix(displayDims.paddedRect.getHeight());
+ Point coords = Widget.calculateCoordinates(elementHeight,
+ elementWidth, displayDims.paddedRect, metrics);
+
+ DisplayDimensions dims = widget.getWidgetDimensions();
+
+ if (isDrawOutlineShadowsEnabled) {
+ canvas.drawRect(dims.canvasRect, outlineShadowPaint);
+ }
+
+ // not positive why this is, but the rect clipped by clipRect is 1 less than the one drawn by drawRect.
+ // so this is necessary to avoid clipping borders. I suspect that its a floating point
+ // jitter issue.
+ if (widget.isClippingEnabled()) {
+ canvas.clipRect(dims.canvasRect, Canvas.ClipOp.INTERSECT);
+ }
+ widget.draw(canvas);
+
+ if (isDrawMarginsEnabled) {
+ drawSpacing(canvas, dims.canvasRect, dims.marginatedRect, getMarginPaint());
+ }
+
+ if (isDrawPaddingEnabled) {
+ drawSpacing(canvas, dims.marginatedRect, dims.paddedRect, getPaddingPaint());
+ }
+
+ if (isDrawAnchorsEnabled) {
+ Point anchorCoords =
+ Widget.getAnchorCoordinates(coords.getPointX(), coords.getPointY(), elementWidth,
+ elementHeight, metrics.getAnchor());
+ drawAnchor(canvas, anchorCoords);
+ }
+
+ if (isDrawOutlinesEnabled) {
+ canvas.drawRect(dims.canvasRect, outlinePaint);
+ }
+ } finally {
+ canvas.restore();
+ }
+ }
+ }
+
+ private static void drawSpacing(Canvas canvas, RectFloat outer, RectFloat inner, Paint paint) {
+ try {
+ canvas.save();
+ canvas.clipRect(inner, Canvas.ClipOp.DIFFERENCE);
+ canvas.drawRect(outer, paint);
+ } finally {
+ canvas.restore();
+ }
+ }
+
+ /**
+ * drawAnchor
+ *
+ * @param canvas canvas
+ * @param coords coords
+ */
+ protected void drawAnchor(Canvas canvas, Point coords) {
+ float anchorSize = Constants.INT_4;
+ canvas.drawRect(coords.getPointX() - anchorSize,
+ coords.getPointY() - anchorSize,
+ coords.getPointX() + anchorSize,
+ coords.getPointY() + anchorSize,
+ anchorPaint);
+ }
+
+ public boolean isDrawOutlinesEnabled() {
+ return isDrawOutlinesEnabled;
+ }
+
+ public void setDrawOutlinesEnabled(boolean isEnabled) {
+ this.isDrawOutlinesEnabled = isEnabled;
+ }
+
+ public Paint getOutlinePaint() {
+ return outlinePaint;
+ }
+
+ public void setOutlinePaint(Paint outlinePaint) {
+ this.outlinePaint = outlinePaint;
+ }
+
+ public boolean isDrawAnchorsEnabled() {
+ return isDrawAnchorsEnabled;
+ }
+
+ public void setDrawAnchorsEnabled(boolean isEnabled) {
+ this.isDrawAnchorsEnabled = isEnabled;
+ }
+
+ public boolean isDrawMarginsEnabled() {
+ return isDrawMarginsEnabled;
+ }
+
+ public void setDrawMarginsEnabled(boolean isEnabled) {
+ this.isDrawMarginsEnabled = isEnabled;
+ }
+
+ public Paint getMarginPaint() {
+ return marginPaint;
+ }
+
+ public void setMarginPaint(Paint marginPaint) {
+ this.marginPaint = marginPaint;
+ }
+
+ public boolean isDrawPaddingEnabled() {
+ return isDrawPaddingEnabled;
+ }
+
+ public void setDrawPaddingEnabled(boolean isEnabled) {
+ this.isDrawPaddingEnabled = isEnabled;
+ }
+
+ public Paint getPaddingPaint() {
+ return paddingPaint;
+ }
+
+ public void setPaddingPaint(Paint paddingPaint) {
+ this.paddingPaint = paddingPaint;
+ }
+
+ public boolean isDrawOutlineShadowsEnabled() {
+ return isDrawOutlineShadowsEnabled;
+ }
+
+ /**
+ * setDrawOutlineShadowsEnabled
+ *
+ * @param isEnabled isEnabled
+ */
+ public void setDrawOutlineShadowsEnabled(boolean isEnabled) {
+ this.isDrawOutlineShadowsEnabled = isEnabled;
+ if (isDrawOutlineShadowsEnabled && outlineShadowPaint == null) {
+ // use a default shadow effect in the case where none has been set:
+ outlineShadowPaint = new Paint();
+ outlineShadowPaint.setColor(Color.DKGRAY);
+ outlineShadowPaint.setStyle(Paint.Style.FILL_STYLE);
+ outlineShadowPaint.setMaskFilter(new MaskFilter(Constants.INT_3, MaskFilter.Blur.NORMAL));
+ outlineShadowPaint.setBlurDrawLooper(new BlurDrawLooper(
+ Constants.INT_3, Constants.INT_5, Constants.INT_5, new Color(Color.BLACK.getValue())));
+ }
+ }
+
+ public Paint getOutlineShadowPaint() {
+ return outlineShadowPaint;
+ }
+
+ public void setOutlineShadowPaint(Paint outlineShadowPaint) {
+ this.outlineShadowPaint = outlineShadowPaint;
+ }
+
+ /**
+ * Recalculates layouts for all widgets using last set
+ * DisplayDimensions. Care should be excersized when choosing when
+ * to call this method as it is a relatively slow operation.
+ */
+ public void refreshLayout() {
+ for (Widget widget : elements()) {
+ widget.layout(displayDims);
+ }
+ }
+
+ @Override
+ public void layout(final DisplayDimensions dims) {
+ this.displayDims = dims;
+
+ refreshLayout();
+ }
+
+ @Override
+ public boolean onTouchEvent(Component component, TouchEvent touchEvent) {
+ return false;
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/LayoutMetric.java b/ohosplot_core/src/main/java/com/ohosplot/ui/LayoutMetric.java
similarity index 72%
rename from androidplot-core/src/main/java/com/androidplot/ui/LayoutMetric.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/LayoutMetric.java
index 2fd5e19d9649a473d6c5252369a20701285632b0..cce31f4d80b4e7a7c812ff55cc3189f2647b9478 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/LayoutMetric.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/LayoutMetric.java
@@ -1,69 +1,79 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-
-
-abstract class LayoutMetric {
-
- private LayoutType layoutType;
-
- //private LayoutType layoutType;
- private float value;
- //private float lastRow;
-
- public LayoutMetric(float value, LayoutType layoutType) {
- validatePair(value, layoutType);
- set(value, layoutType);
- //setLayoutType(layoutType);
- //setValue(value);
- //setLayoutType(layoutType);
- }
-
- /**
- * Verifies that the values passed in are valid for the layout algorithm being used.
- * @param value
- * @param layoutType
- */
- protected abstract void validatePair(float value, LayoutType layoutType);
-
- public void set(float value, LayoutType layoutType) {
- validatePair(value, layoutType);
- this.value = value;
- this.layoutType = layoutType;
- }
-
- public float getValue() {
- return value;
- }
-
- public void setValue(float value) {
- validatePair(value, layoutType);
- this.value = value;
- }
-
- public abstract float getPixelValue(float size);
-
- public LayoutType getLayoutType() {
- return layoutType;
- }
-
- public void setLayoutType(LayoutType layoutType) {
- validatePair(value, layoutType);
- this.layoutType = layoutType;
- }
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+/**
+ * LayoutMetric
+ *
+ * @param
+ * @since 2021-07-22
+ */
+abstract class LayoutMetric {
+ private LayoutType layoutType;
+ private float value;
+
+ /**
+ * LayoutMetric
+ *
+ * @param value value
+ * @param layoutType layoutType
+ */
+ LayoutMetric(float value, LayoutType layoutType) {
+ validatePair(value, layoutType);
+ set(value, layoutType);
+ }
+
+ /**
+ * Verifies that the values passed in are valid for the layout algorithm being used.
+ *
+ * @param value value
+ * @param layoutType layoutType
+ */
+ protected abstract void validatePair(float value, LayoutType layoutType);
+
+ /**
+ * set
+ *
+ * @param va value
+ * @param layType layoutType
+ */
+ public void set(float va, LayoutType layType) {
+ validatePair(va, layType);
+ this.value = va;
+ this.layoutType = layType;
+ }
+
+ public float getValue() {
+ return value;
+ }
+
+ public void setValue(float value) {
+ validatePair(value, layoutType);
+ this.value = value;
+ }
+
+ public abstract float getPixelValue(float size);
+
+ public LayoutType getLayoutType() {
+ return layoutType;
+ }
+
+ public void setLayoutType(LayoutType layoutType) {
+ validatePair(value, layoutType);
+ this.layoutType = layoutType;
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/PositionMetric.java b/ohosplot_core/src/main/java/com/ohosplot/ui/PositionMetric.java
similarity index 58%
rename from androidplot-core/src/main/java/com/androidplot/ui/PositionMetric.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/PositionMetric.java
index 6cf1463c705d7b1f73e51b18d42a4d3c2162d277..15561d50b0800abb202c5112816e18cfa1e67018 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/PositionMetric.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/PositionMetric.java
@@ -1,87 +1,136 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-public abstract class PositionMetric extends LayoutMetric {
-
- protected enum Origin {
- FROM_BEGINING,
- FROM_CENTER,
- FROM_END
- }
-
- protected enum LayoutMode {
- ABSOLUTE,
- RELATIVE
- }
-
- public PositionMetric(float value, LayoutType layoutType) {
- super(value, layoutType);
- }
-
- /**
- * Throws IllegalArgumentException if there is a problem.
- * @param value
- * @param layoutMode
- * @throws IllegalArgumentException
- */
- protected static void validateValue(float value, LayoutMode layoutMode) throws IllegalArgumentException {
- switch(layoutMode) {
- case ABSOLUTE:
- break;
- case RELATIVE:
- if(value < -1 || value > 1) {
- throw new IllegalArgumentException("Relative layout values must be within the range of -1 to 1.");
- }
- break;
- default:
- throw new IllegalArgumentException("Unknown LayoutMode: " + layoutMode);
- }
-
- }
-
- protected float getAbsolutePosition(float size, Origin origin) {
- switch(origin) {
- case FROM_BEGINING:
- return getValue();
- case FROM_CENTER:
- return (size/2f) + getValue();
- case FROM_END:
- return size - getValue();
- default:
- throw new IllegalArgumentException("Unsupported Origin: " + origin);
- }
- }
-
- protected float getRelativePosition(float size, Origin origin) {
- //throw new UnsupportedOperationException("Not yet implemented.");
-
- switch(origin) {
- case FROM_BEGINING:
- return size * getValue();
- case FROM_CENTER:
- return (size/2f) + ((size/2f) * getValue());
- case FROM_END:
- return size + (size*getValue());
- default:
- throw new IllegalArgumentException("Unsupported Origin: " + origin);
- }
-
- }
-
-
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+import com.ohosplot.util.Constants;
+
+/**
+ * PositionMetric
+ *
+ * @param
+ * @since 2021-07-22
+ */
+public abstract class PositionMetric extends LayoutMetric {
+ /**
+ * Origin
+ *
+ * @since 2021-07-22
+ */
+ protected enum Origin {
+ /**
+ * FROM_BEGINING
+ */
+ FROM_BEGINING,
+ /**
+ * FROM_CENTER
+ */
+ FROM_CENTER,
+ /**
+ * FROM_END
+ */
+ FROM_END
+ }
+
+ /**
+ * LayoutMode
+ *
+ * @since 2021-07-22
+ */
+ protected enum LayoutMode {
+ /**
+ * ABSOLUTE
+ */
+ ABSOLUTE,
+ /**
+ * RELATIVE
+ */
+ RELATIVE
+ }
+
+ /**
+ * PositionMetric
+ *
+ * @param value value
+ * @param layoutType layoutType
+ */
+ public PositionMetric(float value, LayoutType layoutType) {
+ super(value, layoutType);
+ }
+
+ /**
+ * Throws IllegalArgumentException if there is a problem.
+ *
+ * @param value value
+ * @param layoutMode layoutMode
+ * @throws IllegalArgumentException IllegalArgumentException
+ */
+ protected static void validateValue(float value, LayoutMode layoutMode) throws IllegalArgumentException {
+ switch(layoutMode) {
+ case ABSOLUTE:
+ break;
+ case RELATIVE:
+ if (value < Constants.INT_F1 || value > 1) {
+ throw new IllegalArgumentException("Relative layout values must be within the range of -1 to 1.");
+ }
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown LayoutMode: " + layoutMode);
+ }
+ }
+
+ /**
+ * getAbsolutePosition
+ *
+ * @param size size
+ * @param origin origin
+ * @return float
+ * @throws IllegalArgumentException IllegalArgumentException
+ */
+ protected float getAbsolutePosition(float size, Origin origin) {
+ switch(origin) {
+ case FROM_BEGINING:
+ return getValue();
+ case FROM_CENTER:
+ return size / Constants.FLOAT_2 + getValue();
+ case FROM_END:
+ return size - getValue();
+ default:
+ throw new IllegalArgumentException("Unsupported Origin: " + origin);
+ }
+ }
+
+ /**
+ * getRelativePosition
+ *
+ * @param size size
+ * @param origin origin
+ * @return float
+ * @throws IllegalArgumentException IllegalArgumentException
+ */
+ protected float getRelativePosition(float size, Origin origin) {
+ switch(origin) {
+ case FROM_BEGINING:
+ return size * getValue();
+ case FROM_CENTER:
+ return size / Constants.FLOAT_2 + ((size / Constants.FLOAT_2) * getValue());
+ case FROM_END:
+ return size + (size * getValue());
+ default:
+ throw new IllegalArgumentException("Unsupported Origin: " + origin);
+ }
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/PositionMetrics.java b/ohosplot_core/src/main/java/com/ohosplot/ui/PositionMetrics.java
similarity index 57%
rename from androidplot-core/src/main/java/com/androidplot/ui/PositionMetrics.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/PositionMetrics.java
index 88efddcb621d82dfbb81c9c394210d33b399b503..40d80f88325fecc087ed6af308e2264185481dda 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/PositionMetrics.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/PositionMetrics.java
@@ -1,69 +1,76 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-import android.support.annotation.NonNull;
-
-public class PositionMetrics implements Comparable {
-
- private HorizontalPosition horizontalPosition;
- private VerticalPosition verticalPosition;
- private Anchor anchor;
- private float layerDepth;
-
- public PositionMetrics(float x, HorizontalPositioning horizontalPositioning, float y, VerticalPositioning verticalPositioning, Anchor anchor) {
- setXPositionMetric(new HorizontalPosition(x, horizontalPositioning));
- setYPositionMetric(new VerticalPosition(y, verticalPositioning));
- setAnchor(anchor);
-
- }
-
- public VerticalPosition getYPositionMetric() {
- return verticalPosition;
- }
-
- public void setYPositionMetric(VerticalPosition verticalPosition) {
- this.verticalPosition = verticalPosition;
- }
-
- public Anchor getAnchor() {
- return anchor;
- }
-
- public void setAnchor(Anchor anchor) {
- this.anchor = anchor;
- }
-
- @Override
- public int compareTo(@NonNull PositionMetrics o) {
- if(this.layerDepth < o.layerDepth) {
- return -1;
- } else if(this.layerDepth == o.layerDepth) {
- return 0;
- } else {
- return 1;
- }
- }
-
- public HorizontalPosition getXPositionMetric() {
- return horizontalPosition;
- }
-
- public void setXPositionMetric(HorizontalPosition horizontalPosition) {
- this.horizontalPosition = horizontalPosition;
- }
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+import com.ohosplot.base.NonNull;
+
+/**
+ * PositionMetrics
+ *
+ * @since 2021-07-22
+ */
+public class PositionMetrics implements Comparable {
+ private HorizontalPosition horizontalPosition;
+ private VerticalPosition verticalPosition;
+ private Anchor anchor;
+ private float layerDepth;
+
+ /**
+ * PositionMetrics
+ *
+ * @param xx xx
+ * @param horizontalPositioning horizontalPositioning
+ * @param yy yy
+ * @param verticalPositioning verticalPositioning
+ * @param anchor anchor
+ */
+ public PositionMetrics(float xx, HorizontalPositioning horizontalPositioning,
+ float yy, VerticalPositioning verticalPositioning, Anchor anchor) {
+ setXPositionMetric(new HorizontalPosition(xx, horizontalPositioning));
+ setYPositionMetric(new VerticalPosition(yy, verticalPositioning));
+ setAnchor(anchor);
+ }
+
+ public VerticalPosition getYPositionMetric() {
+ return verticalPosition;
+ }
+
+ public void setYPositionMetric(VerticalPosition verPosition) {
+ this.verticalPosition = verPosition;
+ }
+
+ public Anchor getAnchor() {
+ return anchor;
+ }
+
+ public void setAnchor(Anchor anchor) {
+ this.anchor = anchor;
+ }
+
+ @Override
+ public int compareTo(@NonNull PositionMetrics o) {
+ return Float.compare(this.layerDepth, o.layerDepth);
+ }
+
+ public HorizontalPosition getXPositionMetric() {
+ return horizontalPosition;
+ }
+
+ public void setXPositionMetric(HorizontalPosition horPosition) {
+ this.horizontalPosition = horPosition;
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/RenderBundle.java b/ohosplot_core/src/main/java/com/ohosplot/ui/RenderBundle.java
similarity index 70%
rename from androidplot-core/src/main/java/com/androidplot/ui/RenderBundle.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/RenderBundle.java
index 441e3bfa19617369857e725a8fa8af6d64da5e43..a3baf7d1d42c88ac9fd61a76f4bc535406cb3682 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/RenderBundle.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/RenderBundle.java
@@ -1,47 +1,61 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-import com.androidplot.Series;
-import com.androidplot.xy.XYSeriesFormatter;
-
-public abstract class RenderBundle {
- //private XYDataset series;
- private Series series;
- private SeriesFormatterType formatter;
-
- public RenderBundle(SeriesType series, SeriesFormatterType formatter) {
- this.formatter = formatter;
- this.series = series;
- }
-
- public Series getSeries() {
- return series;
- }
-
- public void setSeries(Series series) {
- this.series = series;
- }
-
- public SeriesFormatterType getFormatter() {
- return formatter;
- }
-
- public void setFormatter(SeriesFormatterType formatter) {
- this.formatter = formatter;
- }
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+import com.ohosplot.Series;
+import com.ohosplot.xy.XYSeriesFormatter;
+
+/**
+ * RenderBundle
+ *
+ * @param
+ * @param
+ * @param
+ * @since 2021-07-22
+ */
+public abstract class RenderBundle {
+ private Series series;
+ private SeriesFormatterType formatter;
+
+ /**
+ * RenderBundle
+ *
+ * @param series series
+ * @param formatter formatter
+ */
+ public RenderBundle(SeriesType series, SeriesFormatterType formatter) {
+ this.formatter = formatter;
+ this.series = series;
+ }
+
+ public Series getSeries() {
+ return series;
+ }
+
+ public void setSeries(Series series) {
+ this.series = series;
+ }
+
+ public SeriesFormatterType getFormatter() {
+ return formatter;
+ }
+
+ public void setFormatter(SeriesFormatterType formatter) {
+ this.formatter = formatter;
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/RenderStack.java b/ohosplot_core/src/main/java/com/ohosplot/ui/RenderStack.java
similarity index 67%
rename from androidplot-core/src/main/java/com/androidplot/ui/RenderStack.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/RenderStack.java
index 9922756340015107fef12211c47a44d43d6a8402..eb4359317202441a2496222001f4680c724eab3b 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/RenderStack.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/RenderStack.java
@@ -14,46 +14,76 @@
* limitations under the License.
*/
-package com.androidplot.ui;
+package com.ohosplot.ui;
-import com.androidplot.Plot;
-import com.androidplot.Series;
+import com.ohosplot.Plot;
+import com.ohosplot.Series;
import java.util.ArrayList;
import java.util.List;
/**
* A stack of series to be rendered. The stack order is immutable but individual elements may be
- * manipulated via the public methods of {@link RenderStack.StackElement}.
+ * manipulated via the public methods of {@link StackElement}.
+ *
+ * @param
+ * @param
+ * @since 2021-07-22
*/
public class RenderStack {
-
private final Plot plot;
-
private final ArrayList> elements;
+ /**
+ * RenderStack
+ *
+ * @param plot plot
+ */
+ public RenderStack(Plot plot) {
+ this.plot = plot;
+ elements = new ArrayList<>(plot.getRegistry().size());
+ }
+
public ArrayList> getElements() {
return elements;
}
/**
* An element on the render stack.
+ *
+ * @param
+ * @param
+ * @since 2021-07-22
*/
public class StackElement {
private SeriesBundle seriesBundle;
private boolean isEnabled = true;
+ /**
+ * StackElement
+ *
+ * @param seriesBundle seriesBundle
+ */
public StackElement(SeriesBundle seriesBundle) {
set(seriesBundle);
}
-
+ /**
+ * SeriesBundle
+ *
+ * @return SeriesBundle
+ */
public SeriesBundle get() {
return seriesBundle;
}
- public void set(SeriesBundle seriesBundle) {
- this.seriesBundle = seriesBundle;
+ /**
+ * set
+ *
+ * @param bundle seriesBundle
+ */
+ public void set(SeriesBundle bundle) {
+ this.seriesBundle = bundle;
}
public boolean isEnabled() {
@@ -61,20 +91,16 @@ public class RenderStack(plot.getRegistry().size());
- }
-
/**
* Syncs the stack structure with plot's current state. Should be called before
* rendering series data to an XYGraphWidget.
@@ -83,19 +109,20 @@ public class RenderStack> pairList
= plot.getRegistry().getSeriesAndFormatterList();
- for(SeriesBundle thisPair: pairList) {
+ for (SeriesBundle thisPair: pairList) {
getElements().add(new StackElement<>(thisPair));
}
}
/**
- * Invokes {@link RenderStack.StackElement#setEnabled(boolean)} with a value
+ * Invokes {@link StackElement#setEnabled(boolean)} with a value
* of false on all stack elements associated with the specified renderer.
- * @param rendererClass
+ *
+ * @param rendererClass rendererClass
*/
public void disable(Class extends SeriesRenderer> rendererClass) {
- for(RenderStack.StackElement element : getElements()) {
- if(element.get().getFormatter().getRendererClass() == rendererClass) {
+ for (StackElement element : getElements()) {
+ if (element.get().getFormatter().getRendererClass() == rendererClass) {
element.setEnabled(false);
}
}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/Resizable.java b/ohosplot_core/src/main/java/com/ohosplot/ui/Resizable.java
similarity index 82%
rename from androidplot-core/src/main/java/com/androidplot/ui/Resizable.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/Resizable.java
index fea8ad158b430fadf72135eb2c0514c0e4bc9116..00da26b085ce8e592f4cf1f180389650f87a093f 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/Resizable.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/Resizable.java
@@ -1,38 +1,40 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-import com.androidplot.util.DisplayDimensions;
-
-/**
- * Used by classes that depend on dimensional values to lay themselves out and draw.
- * Consideration should be given to synchronizing with any draw routines that also
- * exist within the class.
- */
-public interface Resizable {
-
- /**
- * Called when a change to the class' dimensions is made. This method is responsible
- * for cascading calls to update for any logical children of this class, for example
- * the Plot class is responsible for updating the LayoutManager. Note that while dims
- * is marked final in this interface, the compiler will not enforce it. Implementors of
- * this method should take care not to make changes to dims as this will affect parent
- * Resizables in likely undesired ways.
- * @param dims
- */
- void layout(final DisplayDimensions dims);
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+import com.ohosplot.util.DisplayDimensions;
+
+/**
+ * Used by classes that depend on dimensional values to lay themselves out and draw.
+ * Consideration should be given to synchronizing with any draw routines that also
+ * exist within the class.
+ *
+ * @since 2021-07-22
+ */
+public interface Resizable {
+ /**
+ * Called when a change to the class' dimensions is made. This method is responsible
+ * for cascading calls to update for any logical children of this class, for example
+ * the Plot class is responsible for updating the LayoutManager. Note that while dims
+ * is marked final in this interface, the compiler will not enforce it. Implementors of
+ * this method should take care not to make changes to dims as this will affect parent
+ * Resizables in likely undesired ways.
+ *
+ * @param dims dims
+ */
+ void layout(DisplayDimensions dims);
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/SeriesBundle.java b/ohosplot_core/src/main/java/com/ohosplot/ui/SeriesBundle.java
similarity index 80%
rename from androidplot-core/src/main/java/com/androidplot/ui/SeriesBundle.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/SeriesBundle.java
index 6a5e84815317e15d1bc08defe8dde1271298f6c1..225d60556785c35c7a29251e362bace6d8a5eaec 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/SeriesBundle.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/SeriesBundle.java
@@ -14,19 +14,28 @@
* limitations under the License.
*/
-package com.androidplot.ui;
+package com.ohosplot.ui;
-import com.androidplot.Series;
+import com.ohosplot.Series;
/**
* Defines a relationship between a Series instance and other elements needed to unique render that instance
* such as a Formatter etc.
+ *
+ * @param
+ * @param
+ * @since 2021-07-22
*/
public class SeriesBundle {
-
private final SeriesType series;
private final FormatterType formatter;
+ /**
+ * SeriesBundle
+ *
+ * @param series series
+ * @param formatter formatter
+ */
public SeriesBundle(SeriesType series, FormatterType formatter) {
this.series = series;
this.formatter = formatter;
@@ -40,6 +49,12 @@ public class SeriesBundle
+ * @param
+ * @param
+ * @since 2021-07-22
+ */
public abstract class SeriesRenderer
{
-
private PlotType plot;
+ /**
+ * SeriesRenderer
+ *
+ * @param plot plot
+ */
public SeriesRenderer(PlotType plot) {
this.plot = plot;
}
@@ -42,44 +54,62 @@ public abstract class SeriesRenderer
this.plot = plot;
}
+ /**
+ * getFormatter
+ *
+ * @param series series
+ * @return SeriesFormatterType
+ */
public SeriesFormatterType getFormatter(SeriesType series) {
return (SeriesFormatterType) plot.getFormatter(series, getClass());
}
/**
+ * render
*
- * @param canvas
- * @param plotArea
+ * @param canvas canvas
+ * @param plotArea plotArea
+ * @param stack stack
* @param sfPair The series / formatter pair to be rendered
*/
- public void render(Canvas canvas, RectF plotArea, SeriesBundle sfPair, RenderStack stack) {
onRender(canvas, plotArea, sfPair.getSeries(), sfPair.getFormatter(), stack);
}
/**
+ * onRender
*
- * @param canvas
- * @param plotArea
+ * @param canvas canvas
+ * @param plotArea plotArea
* @param series The series to be rendered
* @param formatter The getFormatter that should be used to render the series
* @param stack Ordered list of all series being renderered. May be manipulated by the Renderer
* to gain effect.
*/
- protected abstract void onRender(Canvas canvas, RectF plotArea, SeriesType series,
+ protected abstract void onRender(Canvas canvas, RectFloat plotArea, SeriesType series,
SeriesFormatterType formatter, RenderStack stack);
/**
* Draw the legend icon in the rect passed in.
- * @param canvas
- * @param rect
+ *
+ * @param canvas canvas
+ * @param rect rect
+ * @param formatter formatter
*/
- protected abstract void doDrawLegendIcon(Canvas canvas, RectF rect, SeriesFormatterType formatter);
+ protected abstract void doDrawLegendIcon(Canvas canvas, RectFloat rect, SeriesFormatterType formatter);
- public void drawSeriesLegendIcon(Canvas canvas, RectF rect, SeriesFormatterType formatter) {
+ /**
+ * drawSeriesLegendIcon
+ *
+ * @param canvas canvas
+ * @param rect rect
+ * @param formatter formatter
+ */
+ public void drawSeriesLegendIcon(Canvas canvas, RectFloat rect, SeriesFormatterType formatter) {
try {
canvas.save();
- canvas.clipRect(rect, Region.Op.INTERSECT);
+ canvas.clipRect(rect, Canvas.ClipOp.INTERSECT);
doDrawLegendIcon(canvas, rect, formatter);
} finally {
canvas.restore();
@@ -87,6 +117,7 @@ public abstract class SeriesRenderer
}
/**
+ * getSeriesAndFormatterList
*
* @return A List of all {@link SeriesBundle} instances currently associated
* with this Renderer.
@@ -94,8 +125,8 @@ public abstract class SeriesRenderer
public List> getSeriesAndFormatterList() {
List> results = new ArrayList<>();
List sfList = getPlot().getRegistry().getSeriesAndFormatterList();
- for(SeriesBundle thisPair : sfList) {
- if(thisPair.rendersWith(this)) {
+ for (SeriesBundle thisPair : sfList) {
+ if (thisPair.rendersWith(this)) {
results.add(thisPair);
}
}
@@ -103,16 +134,16 @@ public abstract class SeriesRenderer
}
/**
+ * getSeriesList
*
- * @return
- * @since 0.9.7
+ * @return List
*/
public List getSeriesList() {
List results = new ArrayList<>();
List sfList = getPlot().getRegistry().getSeriesAndFormatterList();
- for(SeriesBundle thisPair : sfList) {
- if(thisPair.rendersWith(this)) {
+ for (SeriesBundle thisPair : sfList) {
+ if (thisPair.rendersWith(this)) {
results.add(thisPair.getSeries());
}
}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/Size.java b/ohosplot_core/src/main/java/com/ohosplot/ui/Size.java
similarity index 78%
rename from androidplot-core/src/main/java/com/androidplot/ui/Size.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/Size.java
index a54619629154267bb588ce0917c67a8feda87f90..03b56bcdbf76af6248b821d186a844b8d8b9fb49 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/Size.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/Size.java
@@ -14,17 +14,19 @@
* limitations under the License.
*/
-package com.androidplot.ui;
+package com.ohosplot.ui;
-import android.graphics.RectF;
-import com.androidplot.util.PixelUtils;
+import ohos.agp.utils.RectFloat;
/**
* Defines physical dimensions & scaling characteristics
+ *
+ * @since 2021-07-22
*/
public class Size {
-
- // convenience value; sets size to 100% width and height of the widget container.
+ /**
+ * convenience value; sets size to 100% width and height of the widget container.
+ */
public static Size FILL = new Size(0, SizeMode.FILL, 0, SizeMode.FILL);
private SizeMetric height;
@@ -32,6 +34,7 @@ public class Size {
/**
* Convenience constructor. Wraps {@link #Size(SizeMetric, SizeMetric)}.
+ *
* @param height Height value used algorithm to calculate the height of the associated widget(s).
* @param heightLayoutType Algorithm used to calculate the height of the associated widget(s).
* @param width Width value used algorithm to calculate the width of the associated widget(s).
@@ -45,8 +48,9 @@ public class Size {
/**
* Creates a new SizeMetrics instance using the specified size layout algorithm and value.
* See {@link SizeMetric} for details on what can be passed in.
- * @param height
- * @param width
+ *
+ * @param height height
+ * @param width width
*/
public Size(SizeMetric height, SizeMetric width) {
this.height = height;
@@ -66,16 +70,17 @@ public class Size {
}
/**
- * Calculates a RectF with calculated width and height. The top-left corner is set to 0,0.
- * @param canvasRect
- * @return
+ * Calculates a RectFloat with calculated width and height. The top-left corner is set to 0,0.
+ *
+ * @param canvasRect canvasRect
+ * @return RectFloat
*/
- public RectF getRectF(RectF canvasRect) {
- return new RectF(
+ public RectFloat getRectFloat(RectFloat canvasRect) {
+ return new RectFloat(
0,
0,
- width.getPixelValue(canvasRect.width()),
- height.getPixelValue(canvasRect.height()));
+ width.getPixelValue(canvasRect.getWidth()),
+ height.getPixelValue(canvasRect.getHeight()));
}
public void setWidth(SizeMetric width) {
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/SizeMetric.java b/ohosplot_core/src/main/java/com/ohosplot/ui/SizeMetric.java
similarity index 75%
rename from androidplot-core/src/main/java/com/androidplot/ui/SizeMetric.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/SizeMetric.java
index d7f3e58b72770e3027f0555c16a17a73726221eb..8b9f553a517268d604e668f11207f4462df48b14 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/SizeMetric.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/SizeMetric.java
@@ -1,62 +1,76 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-/**
- * Encapsulates a sizing algorithm and an associated value.
- *
- * The available algorithms list are stored in the {@link SizeMode} enumeration.
- *
- */
-public class SizeMetric extends LayoutMetric {
-
- public SizeMetric(float value, SizeMode layoutType) {
- super(value, layoutType);
- }
-
- protected void validatePair(float value, SizeMode layoutType) {
- switch(layoutType) {
- case RELATIVE:
- if(value < 0 || value > 1) {
- throw new IllegalArgumentException("SizeMetric Relative and Hybrid layout values must be within the range of 0 to 1.");
- }
- case ABSOLUTE:
- case FILL:
- default:
- break;
- }
- }
-
- @Override
- public float getPixelValue(float size) {
- switch(getLayoutType()) {
- case ABSOLUTE:
- return getValue();
- case RELATIVE:
- return getValue() * size;
- case FILL:
- return size - getValue();
- default:
- throw new IllegalArgumentException("Unsupported LayoutType: " + this.getLayoutType());
- }
- }
-
- @Override
- public void setLayoutType(SizeMode layoutType) {
- super.setLayoutType(layoutType);
- }
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+/**
+ * Encapsulates a sizing algorithm and an associated value.
+ * The available algorithms list are stored in the {@link SizeMode} enumeration.
+ *
+ * @since 2021-07-22
+ */
+public class SizeMetric extends LayoutMetric {
+ /**
+ * SizeMetric
+ *
+ * @param value value
+ * @param layoutType layoutType
+ */
+ public SizeMetric(float value, SizeMode layoutType) {
+ super(value, layoutType);
+ }
+
+ /**
+ * validatePair
+ *
+ * @param value value
+ * @param layoutType layoutType
+ * @throws IllegalArgumentException IllegalArgumentException
+ */
+ protected void validatePair(float value, SizeMode layoutType) {
+ switch(layoutType) {
+ case RELATIVE:
+ if (value < 0 || value > 1) {
+ throw new IllegalArgumentException(
+ "SizeMetric Relative and Hybrid layout values must be within the range of 0 to 1.");
+ }
+ break;
+ case ABSOLUTE:
+ case FILL:
+ default:
+ break;
+ }
+ }
+
+ @Override
+ public float getPixelValue(float size) {
+ switch(getLayoutType()) {
+ case ABSOLUTE:
+ return getValue();
+ case RELATIVE:
+ return getValue() * size;
+ case FILL:
+ return size - getValue();
+ default:
+ throw new IllegalArgumentException("Unsupported LayoutType: " + this.getLayoutType());
+ }
+ }
+
+ @Override
+ public void setLayoutType(SizeMode layoutType) {
+ super.setLayoutType(layoutType);
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/SizeMode.java b/ohosplot_core/src/main/java/com/ohosplot/ui/SizeMode.java
similarity index 90%
rename from androidplot-core/src/main/java/com/androidplot/ui/SizeMode.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/SizeMode.java
index 0d158133e9667fc1b70113efa34e4658e2428d41..899edb2605e63b458566040cc73179ebfb7549a1 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/SizeMode.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/SizeMode.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.androidplot.ui;
+package com.ohosplot.ui;
/**
* Algorithms available for calculating an arbitrary dimension of a widget.
@@ -26,9 +26,20 @@ package com.androidplot.ui;
* is 60; 50% of 120 = 60.
*
* FILL - Widget completely fills along the associated axis, minus the input size value
+ *
+ * @since 2021-07-22
*/
public enum SizeMode {
+ /**
+ * ABSOLUTE
+ */
ABSOLUTE,
+ /**
+ * RELATIVE
+ */
RELATIVE,
+ /**
+ * FILL
+ */
FILL
}
\ No newline at end of file
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/TableModel.java b/ohosplot_core/src/main/java/com/ohosplot/ui/TableModel.java
similarity index 60%
rename from androidplot-core/src/main/java/com/androidplot/ui/TableModel.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/TableModel.java
index d68278165ef5eae4609f268481386f936cb01294..e6ea6d5ca9640d1358d4615fa9ed5a05f5af64d0 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/TableModel.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/TableModel.java
@@ -1,51 +1,88 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-import android.graphics.RectF;
-
-import java.util.Iterator;
-
-public abstract class TableModel {
- private TableOrder order;
-
- protected TableModel(TableOrder order) {
- setOrder(order);
- }
-
- public abstract Iterator getIterator(RectF tableRect, int totalElements);
-
- //public abstract RectF getCellRect(RectF tableRect, int numElements);
-
- public TableOrder getOrder() {
- return order;
- }
-
- public void setOrder(TableOrder order) {
- this.order = order;
- }
-
- public enum Axis {
- ROW,
- COLUMN
- }
-
- public enum CellSizingMethod {
- FIXED,
- FILL
- }
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+import ohos.agp.utils.RectFloat;
+
+import java.util.Iterator;
+
+/**
+ * TableModel
+ *
+ * @since 2021-07-22
+ */
+public abstract class TableModel {
+ private TableOrder order;
+
+ /**
+ * TableModel
+ *
+ * @param order order
+ */
+ protected TableModel(TableOrder order) {
+ setOrder(order);
+ }
+
+ /**
+ * getIterator
+ *
+ * @param tableRect tableRect
+ * @param totalElements totalElements
+ * @return Iterator
+ */
+ public abstract Iterator getIterator(RectFloat tableRect, int totalElements);
+
+ public TableOrder getOrder() {
+ return order;
+ }
+
+ public void setOrder(TableOrder order) {
+ this.order = order;
+ }
+
+ /**
+ * Axis
+ *
+ * @since 2021-07-22
+ */
+ public enum Axis {
+ /**
+ * ROW
+ */
+ ROW,
+ /**
+ * COLUMN
+ */
+ COLUMN
+ }
+
+ /**
+ * CellSizingMethod
+ *
+ * @since 2021-07-22
+ */
+ public enum CellSizingMethod {
+ /**
+ * FIXED
+ */
+ FIXED,
+ /**
+ * FILL
+ */
+ FILL
+ }
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/TableOrder.java b/ohosplot_core/src/main/java/com/ohosplot/ui/TableOrder.java
similarity index 80%
rename from androidplot-core/src/main/java/com/androidplot/ui/TableOrder.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/TableOrder.java
index fcb5b757d362ac3b26d6d6dbd00f1deae41e670b..80d6a566164fdb8ee29bccfbc20a6895c91c67f2 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/TableOrder.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/TableOrder.java
@@ -1,22 +1,33 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-public enum TableOrder {
- ROW_MAJOR, // standard c-style
- COLUMN_MAJOR
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+/**
+ * TableOrder
+ *
+ * @since 2021-07-22
+ */
+public enum TableOrder {
+ /**
+ * standard c-style
+ */
+ ROW_MAJOR,
+ /**
+ * COLUMN_MAJOR
+ */
+ COLUMN_MAJOR
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/TableSizingMethod.java b/ohosplot_core/src/main/java/com/ohosplot/ui/TableSizingMethod.java
similarity index 89%
rename from androidplot-core/src/main/java/com/androidplot/ui/TableSizingMethod.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/TableSizingMethod.java
index d6ab0892bc211883a3a3635108614729d97ba455..356ed438a9956901d279e88de354a0b692d9c8d4 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/TableSizingMethod.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/TableSizingMethod.java
@@ -1,28 +1,36 @@
-/*
- * Copyright 2015 AndroidPlot.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.androidplot.ui;
-
-/**
- * The sizing methods available to a table.
- * AUTO: The table is divided evenly int tableSize/numElements sections.
- * FIXED: Each element in the table has a predefined number of pixels
- * regardless of what the table's dimensions actually are.
- */
-public enum TableSizingMethod {
- AUTO,
- FIXED
-}
+/*
+ * Copyright 2015 AndroidPlot.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ohosplot.ui;
+
+/**
+ * The sizing methods available to a table.
+ * AUTO: The table is divided evenly int tableSize/numElements sections.
+ * FIXED: Each element in the table has a predefined number of pixels
+ * regardless of what the table's dimensions actually are.
+ *
+ * @since 2021-07-22
+ */
+public enum TableSizingMethod {
+ /**
+ * AUTO
+ */
+ AUTO,
+ /**
+ * FIXED
+ */
+ FIXED
+}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/TextOrientation.java b/ohosplot_core/src/main/java/com/ohosplot/ui/TextOrientation.java
similarity index 78%
rename from androidplot-core/src/main/java/com/androidplot/ui/TextOrientation.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/TextOrientation.java
index 219e64e4585acfce79c64c37d71c5febc26888b4..3f8e422db52ada820303fdd42568953e349ab0c8 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/TextOrientation.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/TextOrientation.java
@@ -14,10 +14,24 @@
* limitations under the License.
*/
-package com.androidplot.ui;
+package com.ohosplot.ui;
+/**
+ * TextOrientation
+ *
+ * @since 2021-07-22
+ */
public enum TextOrientation {
+ /**
+ * HORIZONTAL
+ */
HORIZONTAL,
+ /**
+ * VERTICAL_ASCENDING
+ */
VERTICAL_ASCENDING,
+ /**
+ * VERTICAL_DESCENDING
+ */
VERTICAL_DESCENDING
}
diff --git a/androidplot-core/src/main/java/com/androidplot/ui/VerticalPosition.java b/ohosplot_core/src/main/java/com/ohosplot/ui/VerticalPosition.java
similarity index 67%
rename from androidplot-core/src/main/java/com/androidplot/ui/VerticalPosition.java
rename to ohosplot_core/src/main/java/com/ohosplot/ui/VerticalPosition.java
index f8c8b78f042bdd84a4eda5e79f637f0d1c53750e..68338452ff6fd1266e06c28c49864e6639df0588 100644
--- a/androidplot-core/src/main/java/com/androidplot/ui/VerticalPosition.java
+++ b/ohosplot_core/src/main/java/com/ohosplot/ui/VerticalPosition.java
@@ -14,29 +14,44 @@
* limitations under the License.
*/
-package com.androidplot.ui;
+package com.ohosplot.ui;
+/**
+ * VerticalPosition
+ *
+ * @since 2021-07-22
+ */
public class VerticalPosition extends PositionMetric