Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8504949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:10:53+00:00 2026-06-11T02:10:53+00:00

I have some logic which I am using to construct a series of clusters.

  • 0

I have some logic which I am using to construct a series of clusters. So far, to denote the cluster to which each point on the graph belongs to, I am using a series of colours, where points belonging to the same cluster are of the same colour.

Besides that, I would also like to display the centre of each cluster since this will help me see how my cluster building algorithm performs. To do this at the moment, I am writing some text on the graph through the use of the XPointerAnnotation class. The problem with this is that I think that having text on top of points can lead to a messy plot (considering that it is highly likely that there will be hundreds of points).

I thought of drawing lines going outwards, from the centre point to each of the members of its cluster. The problem I am facing is that I can’t quite seem to find the correct method or methods which does that.

I have managed to find the source of XYLineAndShapeRenderer and have tried to use it as a guide, but I still get no custom lines drawn on the plot. I have tried to override the drawPrimaryLine, drawPrimaryLineAsPath and drawSecondaryPass methods, but to no avail.

The code I am using to render the lines is as follows:

int x1 = (int) dataset.getXValue(series, 0);
int y1 = (int) dataset.getYValue(series, 0);

int x2 = (int) dataset.getXValue(series, item);
int y2 = (int) dataset.getYValue(series, item);

g2.drawLine(x1, y1, x2, y2);
System.out.println(String.format("Drawing %d  %d  %d  %d %s", x1, y1, x2, y2, g2.getColor()));

State s = (State) state;
if (item == s.getLastItemIndex()) {
    // draw path
    drawFirstPassShape(g2, pass, series, item, s.seriesPath);
}

The print statement prints the right coordinates and the right colours, so it just seems that the graphics that I am adding is not being rendered. I have tried calling super, both before and after my code is executed but to no avail either.

Any directions would be appreciated.
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:10:55+00:00Added an answer on June 11, 2026 at 2:10 am

    Looking more closely at the code posted, the xy value obtained from the dataset represents a point in data coordinates. Before such a point can be rendered, it must be transformed into graphics coordinates, relative to the dataArea. As an example, drawPrimaryLineAsPath() uses the corresponding axis method, valueToJava2D(), to convert a data value to a graphics coordinate.

    double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
    double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);
    

    Addendum: The drawPrimaryLineAsPath() method is invoked from drawItem() only when drawSeriesLineAsPath is true, e.g. setDrawSeriesLineAsPath(true).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MVC3, and have some logic for changing the culture which all
I am creating a series of UserControls that all have some similar business logic.
I have some logic in onSubmit of the button (which is in Form), which
I have some serialization logic in which I also serialize stl datastructures. Currently I
I have been asked to perform some logic on an integer, which I think
I have some logic in a method that operates on a specified type and
I have some logic that depends upon two properties being set, as it executes
I have some logic in before_save whereby (only) when some conditions are met I
So here is the problem: I have some logic in my application that will
In XCode 4.2, I have some logic tests that I want to exercise against

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.