/achartengine/src/org/achartengine/renderer/XYMultipleSeriesRenderer.java

https://github.com/d4rxh4wx/AChartEngine · Java · 1099 lines · 422 code · 118 blank · 559 comment · 14 complexity · 191b068694c1ba1978cd1ea4b42c312b MD5 · raw file

  1. /**
  2. * Copyright (C) 2009, 2010 SC 4ViewSoft SRL
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.achartengine.renderer;
  17. import java.util.HashMap;
  18. import java.util.LinkedHashMap;
  19. import java.util.Map;
  20. import java.util.TreeMap;
  21. import org.achartengine.util.MathHelper;
  22. import android.graphics.Color;
  23. import android.graphics.Paint.Align;
  24. /**
  25. * Multiple XY series renderer.
  26. */
  27. public class XYMultipleSeriesRenderer extends DefaultRenderer {
  28. /** The X axis title. */
  29. private String mXTitle = "";
  30. /** The Y axis title. */
  31. private String[] mYTitle;
  32. /** The axis title text size. */
  33. private float mAxisTitleTextSize = 12;
  34. /** The start value in the X axis range. */
  35. private double[] mMinX;
  36. /** The end value in the X axis range. */
  37. private double[] mMaxX;
  38. /** The start value in the Y axis range. */
  39. private double[] mMinY;
  40. /** The end value in the Y axis range. */
  41. private double[] mMaxY;
  42. /** The approximative number of labels on the x axis. */
  43. private int mXLabels = 5;
  44. /** The approximative number of labels on the y axis. */
  45. private int mYLabels = 5;
  46. /** The current orientation of the chart. */
  47. private Orientation mOrientation = Orientation.HORIZONTAL;
  48. /** The X axis text labels. */
  49. private Map<Double, String> mXTextLabels = new TreeMap<Double, String>();
  50. /** The Y axis text labels. */
  51. private Map<Integer, Map<Double, String>> mYTextLabels = new LinkedHashMap<Integer, Map<Double, String>>();
  52. /** A flag for enabling or not the pan on the X axis. */
  53. private boolean mPanXEnabled = true;
  54. /** A flag for enabling or not the pan on the Y axis. */
  55. private boolean mPanYEnabled = true;
  56. /** A flag for enabling or not the zoom on the X axis. */
  57. private boolean mZoomXEnabled = true;
  58. /** A flag for enabling or not the zoom on the Y axis . */
  59. private boolean mZoomYEnabled = true;
  60. /** The spacing between bars, in bar charts. */
  61. private double mBarSpacing = 0;
  62. /** The margins colors. */
  63. private int mMarginsColor = NO_COLOR;
  64. /** The pan limits. */
  65. private double[] mPanLimits;
  66. /** The zoom limits. */
  67. private double[] mZoomLimits;
  68. /** The X axis labels rotation angle. */
  69. private float mXLabelsAngle;
  70. /** The Y axis labels rotation angle. */
  71. private float mYLabelsAngle;
  72. /** The initial axis range. */
  73. private Map<Integer, double[]> initialRange = new LinkedHashMap<Integer, double[]>();
  74. /** The point size for charts displaying points. */
  75. private float mPointSize = 3;
  76. /** The grid color. */
  77. private int mGridColor = Color.argb(75, 200, 200, 200);
  78. /** The number of scales. */
  79. private int scalesCount;
  80. /** The X axis labels alignment. */
  81. private Align xLabelsAlign = Align.CENTER;
  82. /** The Y axis labels alignment. */
  83. private Align[] yLabelsAlign;
  84. /** The Y axis alignment. */
  85. private Align[] yAxisAlign;
  86. /** The X axis labels color. */
  87. private int mXLabelsColor = TEXT_COLOR;
  88. /** The Y axis labels color. */
  89. private int[] mYLabelsColor = new int[] { TEXT_COLOR };
  90. private boolean showWeekSeparator = false;
  91. private int weekColor = Color.RED;
  92. private boolean xTextLabelShifted = false;
  93. /**
  94. * An enum for the XY chart orientation of the X axis.
  95. */
  96. public enum Orientation {
  97. HORIZONTAL(0), VERTICAL(90);
  98. /** The rotate angle. */
  99. private int mAngle = 0;
  100. private Orientation(int angle) {
  101. mAngle = angle;
  102. }
  103. /**
  104. * Return the orientation rotate angle.
  105. *
  106. * @return the orientaion rotate angle
  107. */
  108. public int getAngle() {
  109. return mAngle;
  110. }
  111. }
  112. public XYMultipleSeriesRenderer() {
  113. this(1);
  114. }
  115. public XYMultipleSeriesRenderer(int scaleNumber) {
  116. scalesCount = scaleNumber;
  117. initAxesRange(scaleNumber);
  118. }
  119. public void initAxesRange(int scales) {
  120. mYTitle = new String[scales];
  121. yLabelsAlign = new Align[scales];
  122. yAxisAlign = new Align[scales];
  123. mYLabelsColor = new int[scales];
  124. mMinX = new double[scales];
  125. mMaxX = new double[scales];
  126. mMinY = new double[scales];
  127. mMaxY = new double[scales];
  128. for (int i = 0; i < scales; i++) {
  129. mYLabelsColor[i] = TEXT_COLOR;
  130. initAxesRangeForScale(i);
  131. }
  132. }
  133. public void initAxesRangeForScale(int i) {
  134. mMinX[i] = MathHelper.NULL_VALUE;
  135. mMaxX[i] = -MathHelper.NULL_VALUE;
  136. mMinY[i] = MathHelper.NULL_VALUE;
  137. mMaxY[i] = -MathHelper.NULL_VALUE;
  138. double[] range = new double[] { mMinX[i], mMaxX[i], mMinY[i], mMaxY[i] };
  139. initialRange.put(i, range);
  140. mYTitle[i] = "";
  141. mYTextLabels.put(i, new HashMap<Double, String>());
  142. yLabelsAlign[i] = Align.CENTER;
  143. yAxisAlign[i] = Align.LEFT;
  144. }
  145. /**
  146. * Returns the current orientation of the chart X axis.
  147. *
  148. * @return the chart orientation
  149. */
  150. public Orientation getOrientation() {
  151. return mOrientation;
  152. }
  153. /**
  154. * Sets the current orientation of the chart X axis.
  155. *
  156. * @param orientation the chart orientation
  157. */
  158. public void setOrientation(Orientation orientation) {
  159. mOrientation = orientation;
  160. }
  161. /**
  162. * Returns the title for the X axis.
  163. *
  164. * @return the X axis title
  165. */
  166. public String getXTitle() {
  167. return mXTitle;
  168. }
  169. /**
  170. * Sets the title for the X axis.
  171. *
  172. * @param title the X axis title
  173. */
  174. public void setXTitle(String title) {
  175. mXTitle = title;
  176. }
  177. /**
  178. * Returns the title for the Y axis.
  179. *
  180. * @return the Y axis title
  181. */
  182. public String getYTitle() {
  183. return getYTitle(0);
  184. }
  185. /**
  186. * Returns the title for the Y axis.
  187. *
  188. * @param scale the renderer scale
  189. * @return the Y axis title
  190. */
  191. public String getYTitle(int scale) {
  192. return mYTitle[scale];
  193. }
  194. /**
  195. * Sets the title for the Y axis.
  196. *
  197. * @param title the Y axis title
  198. */
  199. public void setYTitle(String title) {
  200. setYTitle(title, 0);
  201. }
  202. /**
  203. * Sets the title for the Y axis.
  204. *
  205. * @param title the Y axis title
  206. * @param scale the renderer scale
  207. */
  208. public void setYTitle(String title, int scale) {
  209. mYTitle[scale] = title;
  210. }
  211. /**
  212. * Returns the axis title text size.
  213. *
  214. * @return the axis title text size
  215. */
  216. public float getAxisTitleTextSize() {
  217. return mAxisTitleTextSize;
  218. }
  219. /**
  220. * Sets the axis title text size.
  221. *
  222. * @param textSize the chart axis text size
  223. */
  224. public void setAxisTitleTextSize(float textSize) {
  225. mAxisTitleTextSize = textSize;
  226. }
  227. /**
  228. * Returns the start value of the X axis range.
  229. *
  230. * @return the X axis range start value
  231. */
  232. public double getXAxisMin() {
  233. return getXAxisMin(0);
  234. }
  235. /**
  236. * Sets the start value of the X axis range.
  237. *
  238. * @param min the X axis range start value
  239. */
  240. public void setXAxisMin(double min) {
  241. setXAxisMin(min, 0);
  242. }
  243. /**
  244. * Returns if the minimum X value was set.
  245. *
  246. * @return the minX was set or not
  247. */
  248. public boolean isMinXSet() {
  249. return isMinXSet(0);
  250. }
  251. /**
  252. * Returns the end value of the X axis range.
  253. *
  254. * @return the X axis range end value
  255. */
  256. public double getXAxisMax() {
  257. return getXAxisMax(0);
  258. }
  259. /**
  260. * Sets the end value of the X axis range.
  261. *
  262. * @param max the X axis range end value
  263. */
  264. public void setXAxisMax(double max) {
  265. setXAxisMax(max, 0);
  266. }
  267. /**
  268. * Returns if the maximum X value was set.
  269. *
  270. * @return the maxX was set or not
  271. */
  272. public boolean isMaxXSet() {
  273. return isMaxXSet(0);
  274. }
  275. /**
  276. * Returns the start value of the Y axis range.
  277. *
  278. * @return the Y axis range end value
  279. */
  280. public double getYAxisMin() {
  281. return getYAxisMin(0);
  282. }
  283. /**
  284. * Sets the start value of the Y axis range.
  285. *
  286. * @param min the Y axis range start value
  287. */
  288. public void setYAxisMin(double min) {
  289. setYAxisMin(min, 0);
  290. }
  291. /**
  292. * Returns if the minimum Y value was set.
  293. *
  294. * @return the minY was set or not
  295. */
  296. public boolean isMinYSet() {
  297. return isMinYSet(0);
  298. }
  299. /**
  300. * Returns the end value of the Y axis range.
  301. *
  302. * @return the Y axis range end value
  303. */
  304. public double getYAxisMax() {
  305. return getYAxisMax(0);
  306. }
  307. /**
  308. * Sets the end value of the Y axis range.
  309. *
  310. * @param max the Y axis range end value
  311. */
  312. public void setYAxisMax(double max) {
  313. setYAxisMax(max, 0);
  314. }
  315. /**
  316. * Returns if the maximum Y value was set.
  317. *
  318. * @return the maxY was set or not
  319. */
  320. public boolean isMaxYSet() {
  321. return isMaxYSet(0);
  322. }
  323. /**
  324. * Returns the start value of the X axis range.
  325. *
  326. * @param scale the renderer scale
  327. * @return the X axis range start value
  328. */
  329. public double getXAxisMin(int scale) {
  330. return mMinX[scale];
  331. }
  332. /**
  333. * Sets the start value of the X axis range.
  334. *
  335. * @param min the X axis range start value
  336. * @param scale the renderer scale
  337. */
  338. public void setXAxisMin(double min, int scale) {
  339. if (!isMinXSet(scale)) {
  340. initialRange.get(scale)[0] = min;
  341. }
  342. mMinX[scale] = min;
  343. }
  344. /**
  345. * Returns if the minimum X value was set.
  346. *
  347. * @param scale the renderer scale
  348. * @return the minX was set or not
  349. */
  350. public boolean isMinXSet(int scale) {
  351. return mMinX[scale] != MathHelper.NULL_VALUE;
  352. }
  353. /**
  354. * Returns the end value of the X axis range.
  355. *
  356. * @param scale the renderer scale
  357. * @return the X axis range end value
  358. */
  359. public double getXAxisMax(int scale) {
  360. return mMaxX[scale];
  361. }
  362. /**
  363. * Sets the end value of the X axis range.
  364. *
  365. * @param max the X axis range end value
  366. * @param scale the renderer scale
  367. */
  368. public void setXAxisMax(double max, int scale) {
  369. if (!isMaxXSet(scale)) {
  370. initialRange.get(scale)[1] = max;
  371. }
  372. mMaxX[scale] = max;
  373. }
  374. /**
  375. * Returns if the maximum X value was set.
  376. *
  377. * @param scale the renderer scale
  378. * @return the maxX was set or not
  379. */
  380. public boolean isMaxXSet(int scale) {
  381. return mMaxX[scale] != -MathHelper.NULL_VALUE;
  382. }
  383. /**
  384. * Returns the start value of the Y axis range.
  385. *
  386. * @param scale the renderer scale
  387. * @return the Y axis range end value
  388. */
  389. public double getYAxisMin(int scale) {
  390. return mMinY[scale];
  391. }
  392. /**
  393. * Sets the start value of the Y axis range.
  394. *
  395. * @param min the Y axis range start value
  396. * @param scale the renderer scale
  397. */
  398. public void setYAxisMin(double min, int scale) {
  399. if (!isMinYSet(scale)) {
  400. initialRange.get(scale)[2] = min;
  401. }
  402. mMinY[scale] = min;
  403. }
  404. /**
  405. * Returns if the minimum Y value was set.
  406. *
  407. * @param scale the renderer scale
  408. * @return the minY was set or not
  409. */
  410. public boolean isMinYSet(int scale) {
  411. return mMinY[scale] != MathHelper.NULL_VALUE;
  412. }
  413. /**
  414. * Returns the end value of the Y axis range.
  415. *
  416. * @param scale the renderer scale
  417. * @return the Y axis range end value
  418. */
  419. public double getYAxisMax(int scale) {
  420. return mMaxY[scale];
  421. }
  422. /**
  423. * Sets the end value of the Y axis range.
  424. *
  425. * @param max the Y axis range end value
  426. * @param scale the renderer scale
  427. */
  428. public void setYAxisMax(double max, int scale) {
  429. if (!isMaxYSet(scale)) {
  430. initialRange.get(scale)[3] = max;
  431. }
  432. mMaxY[scale] = max;
  433. }
  434. /**
  435. * Returns if the maximum Y value was set.
  436. *
  437. * @param scale the renderer scale
  438. * @return the maxY was set or not
  439. */
  440. public boolean isMaxYSet(int scale) {
  441. return mMaxY[scale] != -MathHelper.NULL_VALUE;
  442. }
  443. /**
  444. * Returns the approximate number of labels for the X axis.
  445. *
  446. * @return the approximate number of labels for the X axis
  447. */
  448. public int getXLabels() {
  449. return mXLabels;
  450. }
  451. /**
  452. * Sets the approximate number of labels for the X axis.
  453. *
  454. * @param xLabels the approximate number of labels for the X axis
  455. */
  456. public void setXLabels(int xLabels) {
  457. mXLabels = xLabels;
  458. }
  459. /**
  460. * Adds a new text label for the specified X axis value.
  461. *
  462. * @param x the X axis value
  463. * @param text the text label
  464. * @deprecated use addXTextLabel instead
  465. */
  466. public void addTextLabel(double x, String text) {
  467. addXTextLabel(x, text);
  468. }
  469. /**
  470. * Adds a new text label for the specified X axis value.
  471. *
  472. * @param x the X axis value
  473. * @param text the text label
  474. */
  475. public void addXTextLabel(double x, String text) {
  476. mXTextLabels.put(x, text);
  477. }
  478. /**
  479. * Returns the X axis text label at the specified X axis value.
  480. *
  481. * @param x the X axis value
  482. * @return the X axis text label
  483. */
  484. public String getXTextLabel(Double x) {
  485. return mXTextLabels.get(x);
  486. }
  487. /**
  488. * Returns the X text label locations.
  489. *
  490. * @return the X text label locations
  491. */
  492. public Double[] getXTextLabelLocations() {
  493. return mXTextLabels.keySet().toArray(new Double[0]);
  494. }
  495. /**
  496. * Clears the existing text labels.
  497. *
  498. * @deprecated use clearXTextLabels instead
  499. */
  500. public void clearTextLabels() {
  501. clearXTextLabels();
  502. }
  503. /**
  504. * Clears the existing text labels on the X axis.
  505. */
  506. public void clearXTextLabels() {
  507. mXTextLabels.clear();
  508. }
  509. /**
  510. * Adds a new text label for the specified Y axis value.
  511. *
  512. * @param y the Y axis value
  513. * @param text the text label
  514. */
  515. public void addYTextLabel(double y, String text) {
  516. addYTextLabel(y, text, 0);
  517. }
  518. /**
  519. * Adds a new text label for the specified Y axis value.
  520. *
  521. * @param y the Y axis value
  522. * @param text the text label
  523. * @param scale the renderer scale
  524. */
  525. public void addYTextLabel(double y, String text, int scale) {
  526. mYTextLabels.get(scale).put(y, text);
  527. }
  528. /**
  529. * Returns the Y axis text label at the specified Y axis value.
  530. *
  531. * @param y the Y axis value
  532. * @return the Y axis text label
  533. */
  534. public String getYTextLabel(Double y) {
  535. return getYTextLabel(y, 0);
  536. }
  537. /**
  538. * Returns the Y axis text label at the specified Y axis value.
  539. *
  540. * @param y the Y axis value
  541. * @param scale the renderer scale
  542. * @return the Y axis text label
  543. */
  544. public String getYTextLabel(Double y, int scale) {
  545. return mYTextLabels.get(scale).get(y);
  546. }
  547. /**
  548. * Returns the Y text label locations.
  549. *
  550. * @return the Y text label locations
  551. */
  552. public Double[] getYTextLabelLocations() {
  553. return getYTextLabelLocations(0);
  554. }
  555. /**
  556. * Returns the Y text label locations.
  557. *
  558. * @param scale the renderer scale
  559. * @return the Y text label locations
  560. */
  561. public Double[] getYTextLabelLocations(int scale) {
  562. return mYTextLabels.get(scale).keySet().toArray(new Double[0]);
  563. }
  564. /**
  565. * Clears the existing text labels on the Y axis.
  566. */
  567. public void clearYTextLabels() {
  568. mYTextLabels.clear();
  569. }
  570. /**
  571. * Returns the approximate number of labels for the Y axis.
  572. *
  573. * @return the approximate number of labels for the Y axis
  574. */
  575. public int getYLabels() {
  576. return mYLabels;
  577. }
  578. /**
  579. * Sets the approximate number of labels for the Y axis.
  580. *
  581. * @param yLabels the approximate number of labels for the Y axis
  582. */
  583. public void setYLabels(int yLabels) {
  584. mYLabels = yLabels;
  585. }
  586. /**
  587. * Sets if the chart point values should be displayed as text.
  588. *
  589. * @param display if the chart point values should be displayed as text
  590. * @deprecated use SimpleSeriesRenderer.setDisplayChartValues() instead
  591. */
  592. public void setDisplayChartValues(boolean display) {
  593. SimpleSeriesRenderer[] renderers = getSeriesRenderers();
  594. for (SimpleSeriesRenderer renderer : renderers) {
  595. renderer.setDisplayChartValues(display);
  596. }
  597. }
  598. /**
  599. * Sets the chart values text size.
  600. *
  601. * @param textSize the chart values text size
  602. * @deprecated use SimpleSeriesRenderer.setChartValuesTextSize() instead
  603. */
  604. public void setChartValuesTextSize(float textSize) {
  605. SimpleSeriesRenderer[] renderers = getSeriesRenderers();
  606. for (SimpleSeriesRenderer renderer : renderers) {
  607. renderer.setChartValuesTextSize(textSize);
  608. }
  609. }
  610. /**
  611. * Returns the enabled state of the pan on at least one axis.
  612. *
  613. * @return if pan is enabled
  614. */
  615. public boolean isPanEnabled() {
  616. return isPanXEnabled() || isPanYEnabled();
  617. }
  618. /**
  619. * Returns the enabled state of the pan on X axis.
  620. *
  621. * @return if pan is enabled on X axis
  622. */
  623. public boolean isPanXEnabled() {
  624. return mPanXEnabled;
  625. }
  626. /**
  627. * Returns the enabled state of the pan on Y axis.
  628. *
  629. * @return if pan is enabled on Y axis
  630. */
  631. public boolean isPanYEnabled() {
  632. return mPanYEnabled;
  633. }
  634. /**
  635. * Sets the enabled state of the pan.
  636. *
  637. * @param enabledX pan enabled on X axis
  638. * @param enabledY pan enabled on Y axis
  639. */
  640. public void setPanEnabled(boolean enabledX, boolean enabledY) {
  641. mPanXEnabled = enabledX;
  642. mPanYEnabled = enabledY;
  643. }
  644. /**
  645. * Returns the enabled state of the zoom on at least one axis.
  646. *
  647. * @return if zoom is enabled
  648. */
  649. public boolean isZoomEnabled() {
  650. return isZoomXEnabled() || isZoomYEnabled();
  651. }
  652. /**
  653. * Returns the enabled state of the zoom on X axis.
  654. *
  655. * @return if zoom is enabled on X axis
  656. */
  657. public boolean isZoomXEnabled() {
  658. return mZoomXEnabled;
  659. }
  660. /**
  661. * Returns the enabled state of the zoom on Y axis.
  662. *
  663. * @return if zoom is enabled on Y axis
  664. */
  665. public boolean isZoomYEnabled() {
  666. return mZoomYEnabled;
  667. }
  668. /**
  669. * Sets the enabled state of the zoom.
  670. *
  671. * @param enabledX zoom enabled on X axis
  672. * @param enabledY zoom enabled on Y axis
  673. */
  674. public void setZoomEnabled(boolean enabledX, boolean enabledY) {
  675. mZoomXEnabled = enabledX;
  676. mZoomYEnabled = enabledY;
  677. }
  678. /**
  679. * Returns the spacing between bars, in bar charts.
  680. *
  681. * @return the spacing between bars
  682. * @deprecated use getBarSpacing instead
  683. */
  684. public double getBarsSpacing() {
  685. return getBarSpacing();
  686. }
  687. /**
  688. * Returns the spacing between bars, in bar charts.
  689. *
  690. * @return the spacing between bars
  691. */
  692. public double getBarSpacing() {
  693. return mBarSpacing;
  694. }
  695. /**
  696. * Sets the spacing between bars, in bar charts. Only available for bar
  697. * charts. This is a coefficient of the bar width. For instance, if you want
  698. * the spacing to be a half of the bar width, set this value to 0.5.
  699. *
  700. * @param spacing the spacing between bars coefficient
  701. */
  702. public void setBarSpacing(double spacing) {
  703. mBarSpacing = spacing;
  704. }
  705. /**
  706. * Returns the margins color.
  707. *
  708. * @return the margins color
  709. */
  710. public int getMarginsColor() {
  711. return mMarginsColor;
  712. }
  713. /**
  714. * Sets the color of the margins.
  715. *
  716. * @param color the margins color
  717. */
  718. public void setMarginsColor(int color) {
  719. mMarginsColor = color;
  720. }
  721. /**
  722. * Returns the grid color.
  723. *
  724. * @return the grid color
  725. */
  726. public int getGridColor() {
  727. return mGridColor;
  728. }
  729. /**
  730. * Sets the color of the grid.
  731. *
  732. * @param color the grid color
  733. */
  734. public void setGridColor(int color) {
  735. mGridColor = color;
  736. }
  737. /**
  738. * Returns the pan limits.
  739. *
  740. * @return the pan limits
  741. */
  742. public double[] getPanLimits() {
  743. return mPanLimits;
  744. }
  745. /**
  746. * Sets the pan limits as an array of 4 values. Setting it to null or a
  747. * different size array will disable the panning limitation. Values:
  748. * [panMinimumX, panMaximumX, panMinimumY, panMaximumY]
  749. *
  750. * @param panLimits the pan limits
  751. */
  752. public void setPanLimits(double[] panLimits) {
  753. mPanLimits = panLimits;
  754. }
  755. /**
  756. * Returns the zoom limits.
  757. *
  758. * @return the zoom limits
  759. */
  760. public double[] getZoomLimits() {
  761. return mZoomLimits;
  762. }
  763. /**
  764. * Sets the zoom limits as an array of 4 values. Setting it to null or a
  765. * different size array will disable the zooming limitation. Values:
  766. * [zoomMinimumX, zoomMaximumX, zoomMinimumY, zoomMaximumY]
  767. *
  768. * @param zoomLimits the zoom limits
  769. */
  770. public void setZoomLimits(double[] zoomLimits) {
  771. mZoomLimits = zoomLimits;
  772. }
  773. /**
  774. * Returns the rotation angle of labels for the X axis.
  775. *
  776. * @return the rotation angle of labels for the X axis
  777. */
  778. public float getXLabelsAngle() {
  779. return mXLabelsAngle;
  780. }
  781. /**
  782. * Sets the rotation angle (in degrees) of labels for the X axis.
  783. *
  784. * @param angle the rotation angle of labels for the X axis
  785. */
  786. public void setXLabelsAngle(float angle) {
  787. mXLabelsAngle = angle;
  788. }
  789. /**
  790. * Returns the rotation angle of labels for the Y axis.
  791. *
  792. * @return the approximate number of labels for the Y axis
  793. */
  794. public float getYLabelsAngle() {
  795. return mYLabelsAngle;
  796. }
  797. /**
  798. * Sets the rotation angle (in degrees) of labels for the Y axis.
  799. *
  800. * @param angle the rotation angle of labels for the Y axis
  801. */
  802. public void setYLabelsAngle(float angle) {
  803. mYLabelsAngle = angle;
  804. }
  805. /**
  806. * Returns the size of the points, for charts displaying points.
  807. *
  808. * @return the point size
  809. */
  810. public float getPointSize() {
  811. return mPointSize;
  812. }
  813. /**
  814. * Sets the size of the points, for charts displaying points.
  815. *
  816. * @param size the point size
  817. */
  818. public void setPointSize(float size) {
  819. mPointSize = size;
  820. }
  821. public void setRange(double[] range) {
  822. setRange(range, 0);
  823. }
  824. /**
  825. * Sets the axes range values.
  826. *
  827. * @param range an array having the values in this order: minX, maxX, minY,
  828. * maxY
  829. * @param scale the renderer scale
  830. */
  831. public void setRange(double[] range, int scale) {
  832. setXAxisMin(range[0], scale);
  833. setXAxisMax(range[1], scale);
  834. setYAxisMin(range[2], scale);
  835. setYAxisMax(range[3], scale);
  836. }
  837. public boolean isInitialRangeSet() {
  838. return isInitialRangeSet(0);
  839. }
  840. /**
  841. * Returns if the initial range is set.
  842. *
  843. * @param scale the renderer scale
  844. * @return the initial range was set or not
  845. */
  846. public boolean isInitialRangeSet(int scale) {
  847. return initialRange.get(scale) != null;
  848. }
  849. /**
  850. * Returns the initial range.
  851. *
  852. * @return the initial range
  853. */
  854. public double[] getInitialRange() {
  855. return getInitialRange(0);
  856. }
  857. /**
  858. * Returns the initial range.
  859. *
  860. * @param scale the renderer scale
  861. * @return the initial range
  862. */
  863. public double[] getInitialRange(int scale) {
  864. return initialRange.get(scale);
  865. }
  866. /**
  867. * Sets the axes initial range values. This will be used in the zoom fit tool.
  868. *
  869. * @param range an array having the values in this order: minX, maxX, minY,
  870. * maxY
  871. */
  872. public void setInitialRange(double[] range) {
  873. setInitialRange(range, 0);
  874. }
  875. /**
  876. * Sets the axes initial range values. This will be used in the zoom fit tool.
  877. *
  878. * @param range an array having the values in this order: minX, maxX, minY,
  879. * maxY
  880. * @param scale the renderer scale
  881. */
  882. public void setInitialRange(double[] range, int scale) {
  883. initialRange.put(scale, range);
  884. }
  885. /**
  886. * Returns the X axis labels color.
  887. *
  888. * @return the X axis labels color
  889. */
  890. public int getXLabelsColor() {
  891. return mXLabelsColor;
  892. }
  893. /**
  894. * Returns the Y axis labels color.
  895. *
  896. * @return the Y axis labels color
  897. */
  898. public int getYLabelsColor(int scale) {
  899. return mYLabelsColor[scale];
  900. }
  901. /**
  902. * Sets the X axis labels color.
  903. *
  904. * @param color the X axis labels color
  905. */
  906. public void setXLabelsColor(int color) {
  907. mXLabelsColor = color;
  908. }
  909. /**
  910. * Sets the Y axis labels color.
  911. *
  912. * @param scale the renderer scale
  913. * @param color the Y axis labels color
  914. */
  915. public void setYLabelsColor(int scale, int color) {
  916. mYLabelsColor[scale] = color;
  917. }
  918. /**
  919. * Returns the X axis labels alignment.
  920. *
  921. * @return X labels alignment
  922. */
  923. public Align getXLabelsAlign() {
  924. return xLabelsAlign;
  925. }
  926. /**
  927. * Sets the X axis labels alignment.
  928. *
  929. * @param align the X labels alignment
  930. */
  931. public void setXLabelsAlign(Align align) {
  932. xLabelsAlign = align;
  933. }
  934. /**
  935. * Returns the Y axis labels alignment.
  936. *
  937. * @param scale the renderer scale
  938. * @return Y labels alignment
  939. */
  940. public Align getYLabelsAlign(int scale) {
  941. return yLabelsAlign[scale];
  942. }
  943. public void setYLabelsAlign(Align align) {
  944. setYLabelsAlign(align, 0);
  945. }
  946. public Align getYAxisAlign(int scale) {
  947. return yAxisAlign[scale];
  948. }
  949. public void setYAxisAlign(Align align, int scale) {
  950. yAxisAlign[scale] = align;
  951. }
  952. /**
  953. * Sets the Y axis labels alignment.
  954. *
  955. * @param align the Y labels alignment
  956. */
  957. public void setYLabelsAlign(Align align, int scale) {
  958. yLabelsAlign[scale] = align;
  959. }
  960. public int getScalesCount() {
  961. return scalesCount;
  962. }
  963. public int getWeekColor() {
  964. return weekColor;
  965. }
  966. public void setWeekColor(int weekColor) {
  967. this.weekColor = weekColor;
  968. }
  969. public boolean isShowWeekSeparator() {
  970. return showWeekSeparator;
  971. }
  972. public void setShowWeekSeparator(boolean showWeekSeparator) {
  973. this.showWeekSeparator = showWeekSeparator;
  974. }
  975. public boolean isXTextLabelShifted() {
  976. return xTextLabelShifted;
  977. }
  978. public void setXTextLabelShifted(boolean xTextLabelShifted) {
  979. this.xTextLabelShifted = xTextLabelShifted;
  980. }
  981. }