@PBoucher Also consider moving stuff in some reasonable methods that puts close related stuff together.
- Try to use meaningful names, stuff like "m_bS2Bypass" that is presumably IDE generated variable name is just rubbish.
- Simplify if/else statements as this is disaster and can easily lead logical flows
if(!m_bBypassIso && ((m_bS1Power && m_bS1Switch && !(m_bS1BypassPos||m_bS2BypassPos)) || (m_bS2Power && m_bS2Switch && !(m_bS1BypassPos||m_bS2BypassPos))) || ((m_bS1Power && m_bS1BypassPos && m_bS1Bypass) || (m_bS2Power && m_bS2BypassPos && m_bS2Bypass)) )
Wouldn't be easier to establish when to use black colour instead of this complex statement for red?
- Check for repeating patterns
//Source 1 g2d.drawLine(220, 0, 210, 10); // / g2d.drawLine(210, 10, 220, 20); // \ g2d.drawLine(210, 10, 95, 10); // - if(m_bBypassIso) { g2d.drawLine(75, 10, 105, 10); // - g2d.drawLine(85, 0, 75, 10); // / g2d.drawLine(75, 10, 85, 20); // \ g2d.setColor(Color.black); }
and replace them with simple method calls where you just pass some data for computation
drawLines(g2d, Arrays.asList(new DrawPoints(220, 0, 210, 10), new DrawPoints(210, 10, 220, 20), new DrawPoints(210, 10, 95, 10)); public void drawLines(Graphics2D g2d, List<DrawPoints> list){ for(DrawPoint each : list){ g2d.drawLine(each.getX1(), each.getY1(), each.getX2(), each.getY2()); } }