home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (MyColor.groovy)

This example Groovy source code file (MyColor.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

awt, color, color, mycolor, mycolor, string, string

The Groovy MyColor.groovy source code

package groovy.operator

import java.awt.Color

class MyColor {
    Color delegate

    MyColor(int r, int g, int b) {
        delegate = new Color(r, g, b)

    MyColor negative() {
        return new MyColor(delegate.red.intdiv(2), delegate.green.intdiv(2), delegate.blue.intdiv(2))

    MyColor positive() {
        return new MyColor(2 * delegate.red - 1, 2 * delegate.green - 1, 2 * delegate.blue - 1)

    String toString() {
        return delegate.toString()

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy MyColor.groovy source code file:

my book on functional programming


new blog posts


Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.