GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Set those sizes to dps, convert internally. · FlyingAndroid/MPAndroidChart@38cdf1b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • MPChartLib/src/main/java/com/github/mikephil/charting
    • components
      • Legend.java
    • renderer
      • LegendRenderer.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎MPChartLib/src/main/java/com/github/mikephil/charting/components/Legend.java‎

Copy file name to clipboardExpand all lines: MPChartLib/src/main/java/com/github/mikephil/charting/components/Legend.java
+23-23Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,7 @@ public enum LegendDirection {
161161
*/
162162
public Legend() {
163163

164-
mFormSize = Utils.convertDpToPixel(8f);
165-
mFormLineWidth = Utils.convertDpToPixel(3f);
166-
mXEntrySpace = Utils.convertDpToPixel(6f);
167-
mYEntrySpace = Utils.convertDpToPixel(0f);
168-
mFormToTextSpace = Utils.convertDpToPixel(5f);
169-
mTextSize = Utils.convertDpToPixel(10f);
170-
mStackSpace = Utils.convertDpToPixel(3f);
164+
this.mTextSize = Utils.convertDpToPixel(10f);
171165
this.mXOffset = Utils.convertDpToPixel(5f);
172166
this.mYOffset = Utils.convertDpToPixel(3f); // 2
173167
}
@@ -248,10 +242,12 @@ public float getMaximumEntryWidth(Paint p) {
248242

249243
float max = 0f;
250244
float maxFormSize = 0f;
245+
float formToTextSpace = Utils.convertDpToPixel(mFormToTextSpace);
251246

252247
for (LegendEntry entry : mEntries) {
253-
final float formSize = Float.isNaN(entry.formSize)
254-
? mFormSize : entry.formSize;
248+
final float formSize = Utils.convertDpToPixel(
249+
Float.isNaN(entry.formSize)
250+
? mFormSize : entry.formSize);
255251
if (formSize > maxFormSize)
256252
maxFormSize = formSize;
257253

@@ -264,7 +260,7 @@ public float getMaximumEntryWidth(Paint p) {
264260
max = length;
265261
}
266262

267-
return max + maxFormSize + mFormToTextSpace;
263+
return max + maxFormSize + formToTextSpace;
268264
}
269265

270266
/**
@@ -643,7 +639,7 @@ public void setForm(LegendForm shape) {
643639
* @param size
644640
*/
645641
public void setFormSize(float size) {
646-
mFormSize = Utils.convertDpToPixel(size);
642+
mFormSize = size;
647643
}
648644

649645
/**
@@ -661,7 +657,7 @@ public float getFormSize() {
661657
* @param size
662658
*/
663659
public void setFormLineWidth(float size) {
664-
mFormLineWidth = Utils.convertDpToPixel(size);
660+
mFormLineWidth = size;
665661
}
666662

667663
/**
@@ -706,7 +702,7 @@ public float getXEntrySpace() {
706702
* @param space
707703
*/
708704
public void setXEntrySpace(float space) {
709-
mXEntrySpace = Utils.convertDpToPixel(space);
705+
mXEntrySpace = space;
710706
}
711707

712708
/**
@@ -725,7 +721,7 @@ public float getYEntrySpace() {
725721
* @param space
726722
*/
727723
public void setYEntrySpace(float space) {
728-
mYEntrySpace = Utils.convertDpToPixel(space);
724+
mYEntrySpace = space;
729725
}
730726

731727
/**
@@ -744,7 +740,7 @@ public float getFormToTextSpace() {
744740
* @param space
745741
*/
746742
public void setFormToTextSpace(float space) {
747-
this.mFormToTextSpace = Utils.convertDpToPixel(space);
743+
this.mFormToTextSpace = space;
748744
}
749745

750746
/**
@@ -858,11 +854,11 @@ public List<FSize> getCalculatedLineSizes() {
858854
*/
859855
public void calculateDimensions(Paint labelpaint, ViewPortHandler viewPortHandler) {
860856

861-
float defaultFormSize = mFormSize;
862-
float stackSpace = mStackSpace;
863-
float formToTextSpace = mFormToTextSpace;
864-
float xEntrySpace = mXEntrySpace;
865-
float yEntrySpace = mYEntrySpace;
857+
float defaultFormSize = Utils.convertDpToPixel(mFormSize);
858+
float stackSpace = Utils.convertDpToPixel(mStackSpace);
859+
float formToTextSpace = Utils.convertDpToPixel(mFormToTextSpace);
860+
float xEntrySpace = Utils.convertDpToPixel(mXEntrySpace);
861+
float yEntrySpace = Utils.convertDpToPixel(mYEntrySpace);
866862
boolean wordWrapEnabled = mWordWrapEnabled;
867863
LegendEntry[] entries = mEntries;
868864
int entryCount = entries.length;
@@ -881,7 +877,9 @@ public void calculateDimensions(Paint labelpaint, ViewPortHandler viewPortHandle
881877

882878
LegendEntry e = entries[i];
883879
boolean drawingForm = e.form != LegendForm.NONE;
884-
float formSize = Float.isNaN(e.formSize) ? defaultFormSize : e.formSize;
880+
float formSize = Float.isNaN(e.formSize)
881+
? defaultFormSize
882+
: Utils.convertDpToPixel(e.formSize);
885883
String label = e.label;
886884

887885
if (!wasStacked)
@@ -945,7 +943,9 @@ else if (wasStacked) {
945943

946944
LegendEntry e = entries[i];
947945
boolean drawingForm = e.form != LegendForm.NONE;
948-
float formSize = Float.isNaN(e.formSize) ? defaultFormSize : e.formSize;
946+
float formSize = Float.isNaN(e.formSize)
947+
? defaultFormSize
948+
: Utils.convertDpToPixel(e.formSize);
949949
String label = e.label;
950950

951951
mCalculatedLabelBreakPoints.add(false);
@@ -963,7 +963,7 @@ else if (wasStacked) {
963963
if (label != null) {
964964

965965
mCalculatedLabelSizes.add(Utils.calcTextSize(labelpaint, label));
966-
requiredWidth += drawingForm ? mFormToTextSpace + formSize : 0.f;
966+
requiredWidth += drawingForm ? formToTextSpace + formSize : 0.f;
967967
requiredWidth += mCalculatedLabelSizes.get(i).width;
968968
} else {
969969

Collapse file

‎MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LegendRenderer.java‎

Copy file name to clipboardExpand all lines: MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LegendRenderer.java
+16-11Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,21 +236,22 @@ public void renderLegend(Canvas c) {
236236
mLegendLabelPaint.setColor(mLegend.getTextColor());
237237

238238
float labelLineHeight = Utils.getLineHeight(mLegendLabelPaint, legendFontMetrics);
239-
float labelLineSpacing = Utils.getLineSpacing(mLegendLabelPaint, legendFontMetrics) + mLegend.getYEntrySpace();
239+
float labelLineSpacing = Utils.getLineSpacing(mLegendLabelPaint, legendFontMetrics)
240+
+ Utils.convertDpToPixel(mLegend.getYEntrySpace());
240241
float formYOffset = labelLineHeight - Utils.calcTextHeight(mLegendLabelPaint, "ABC") / 2.f;
241242

242243
LegendEntry[] entries = mLegend.getEntries();
243244

244-
float formToTextSpace = mLegend.getFormToTextSpace();
245-
float xEntrySpace = mLegend.getXEntrySpace();
245+
float formToTextSpace = Utils.convertDpToPixel(mLegend.getFormToTextSpace());
246+
float xEntrySpace = Utils.convertDpToPixel(mLegend.getXEntrySpace());
246247
Legend.LegendOrientation orientation = mLegend.getOrientation();
247248
Legend.LegendHorizontalAlignment horizontalAlignment = mLegend.getHorizontalAlignment();
248249
Legend.LegendVerticalAlignment verticalAlignment = mLegend.getVerticalAlignment();
249250
Legend.LegendDirection direction = mLegend.getDirection();
250-
float defaultFormSize = mLegend.getFormSize();
251+
float defaultFormSize = Utils.convertDpToPixel(mLegend.getFormSize());
251252

252253
// space between the entries
253-
float stackSpace = mLegend.getStackSpace();
254+
float stackSpace = Utils.convertDpToPixel(mLegend.getStackSpace());
254255

255256
float yoffset = mLegend.getYOffset();
256257
float xoffset = mLegend.getXOffset();
@@ -334,7 +335,7 @@ public void renderLegend(Canvas c) {
334335

335336
LegendEntry e = entries[i];
336337
boolean drawingForm = e.form != Legend.LegendForm.NONE;
337-
float formSize = Float.isNaN(e.formSize) ? defaultFormSize : e.formSize;
338+
float formSize = Float.isNaN(e.formSize) ? defaultFormSize : Utils.convertDpToPixel(e.formSize);
338339

339340
if (i < calculatedLabelBreakPoints.size() && calculatedLabelBreakPoints.get(i)) {
340341
posX = originPosX;
@@ -415,7 +416,7 @@ public void renderLegend(Canvas c) {
415416

416417
LegendEntry e = entries[i];
417418
boolean drawingForm = e.form != Legend.LegendForm.NONE;
418-
float formSize = Float.isNaN(e.formSize) ? defaultFormSize : e.formSize;
419+
float formSize = Float.isNaN(e.formSize) ? defaultFormSize : Utils.convertDpToPixel(e.formSize);
419420

420421
float posX = originPosX;
421422

@@ -495,7 +496,10 @@ protected void drawForm(
495496

496497
mLegendFormPaint.setColor(entry.formColor);
497498

498-
final float formSize = Float.isNaN(entry.formSize) ? legend.getFormSize() : entry.formSize;
499+
final float formSize = Utils.convertDpToPixel(
500+
Float.isNaN(entry.formSize)
501+
? legend.getFormSize()
502+
: entry.formSize);
499503
final float half = formSize / 2f;
500504

501505
switch (form) {
@@ -520,9 +524,10 @@ protected void drawForm(
520524

521525
case LINE:
522526
{
523-
final float formLineWidth = Float.isNaN(entry.formLineWidth)
524-
? legend.getFormLineWidth()
525-
: entry.formLineWidth;
527+
final float formLineWidth = Utils.convertDpToPixel(
528+
Float.isNaN(entry.formLineWidth)
529+
? legend.getFormLineWidth()
530+
: entry.formLineWidth);
526531
final DashPathEffect formLineDashEffect = entry.formLineDashEffect == null
527532
? legend.getFormLineDashEffect()
528533
: entry.formLineDashEffect;

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.