chart: чёрный контур up/down bars биржевой диаграммы
PR checks / web (pull_request) Successful in 41s
PR checks / java (pull_request) Successful in 1m1s
Main: tests, deploy, autotests / web (push) Successful in 39s
Main: tests, deploy, autotests / java (push) Successful in 59s
Main: tests, deploy, autotests / images-web (push) Successful in 1m23s
Main: tests, deploy, autotests / images-app (push) Successful in 3m44s
Main: tests, deploy, autotests / deploy (push) Successful in 1m32s
Main: tests, deploy, autotests / autotests (push) Successful in 36s
Main: tests, deploy, autotests / rollback (push) Has been skipped

StockPainter рисовал c:upBars/c:downBars только заливкой — белые up-столбцы
невидимы на белом фоне (Word обводит их контуром). Теперь столбец обводится:
цвет/ширина из c:spPr/a:ln (solidFill/@w), явный a:ln/a:noFill — без контура,
дефолт — чёрный 0.75pt. Регрессии: StockPainterTest#upDownBars_whiteFillBlackOutline,
ChartSpecTest#stockUpDownBarLinesParsed.
This commit was merged in pull request #57.
This commit is contained in:
Pjandro
2026-10-26 09:59:21 +00:00
parent fba9a492f0
commit 89e76be289
5 changed files with 121 additions and 4 deletions
@@ -1386,6 +1386,31 @@ class ChartSpecTest {
assertEquals(3, spec.series.size());
}
/** c:upBars/c:downBars a:ln: solidFill+@w → цвет/ширина; noFill → без контура. */
@Test
void stockUpDownBarLinesParsed() {
CTUpDownBars u = upDownBars();
CTLineProperties upLn = new CTLineProperties();
upLn.setSolidFill(fill("000000"));
upLn.setW(12700);
u.getUpBars().getSpPr().setLn(upLn);
CTLineProperties downLn = new CTLineProperties();
downLn.setNoFill(new CTNoFillProperties());
u.getDownBars().getSpPr().setLn(downLn);
CTStockChart chart = new CTStockChart();
chart.setUpDownBars(u);
chart.getSer().add(new CTLineSer());
chart.getSer().add(new CTLineSer());
ChartSpec spec = new ChartSpec();
ChartSpec.readGroup(chart, spec, new DrawMlColor(null), List.of());
assertEquals(Color.BLACK, spec.upLine);
assertEquals(1.0, spec.upLineWidth, 0.001);
assertNull(spec.downLine);
assertTrue(spec.downLineNoFill);
assertEquals(0.75, spec.downLineWidth, 0.001,
"без a:ln/@w — дефолт 0.75");
}
/** c:ofPieChart: custSplit → secondPiePts, percent/pos со splitPos, auto-дефолт. */
@Test
void ofPieSplitParsed() {
@@ -20,6 +20,8 @@ class StockPainterTest {
private static final Color UP = StockPainter.UP_FILL;
private static final Color DOWN = StockPainter.DOWN_FILL;
private static final Color DROP = StockPainter.DROP_COLOR;
/** Порог альфы «непрозрачный» для countOpaqueBlack. */
private static final int OPAQUE_ALPHA_MIN = 128;
/** hiLowLines: вертикаль цвета HI_LOW появляется только с элементом. */
@Test
@@ -45,6 +47,19 @@ class StockPainterTest {
"upDownBars «вниз» не нарисована (последний ряд ниже первого)");
}
/** Белая заливка up/down bars: Word обводит столбцы чёрным контуром (видимость на белом фоне). */
@Test
void upDownBars_whiteFillBlackOutline() {
ChartSpec up = stockSpec(false, true, false);
up.upFill = Color.WHITE;
up.downFill = Color.WHITE;
assertTrue(countOpaqueBlack(render(up)) > 0,
"чёрный контур up/down bars не нарисован");
ChartSpec bare = stockSpec(false, false, false);
assertEquals(0, countOpaqueBlack(render(bare)),
"чёрный вне upDownBars — контроль: без столбцов непрозрачного чёрного нет");
}
/** dropLines: вертикали до базовой линии только с элементом. */
@Test
void dropLines_drawnToBaseline() {
@@ -139,4 +154,25 @@ class StockPainterTest {
}
return n;
}
/** Непрозрачные чёрные px: прозрачные углы скруглённого rect chartSpace
* (TYPE_INT_ARGB) читаются getRGB как rgb=0 и в зачёт идти не должны. */
private static long countOpaqueBlack(BufferedImage img) {
long n = 0;
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
int rgb = img.getRGB(x, y);
if ((rgb >>> 24) < OPAQUE_ALPHA_MIN) {
continue;
}
int r = (rgb >> 16) & 0xFF;
int g = (rgb >> 8) & 0xFF;
int b = rgb & 0xFF;
if (r <= 24 && g <= 24 && b <= 24) {
n++;
}
}
}
return n;
}
}